tail does not exit

Max N. Boyarov m.boyarov at bsd.by
Wed Dec 19 17:18:18 PST 2007


>>>>> "MT" == Mikhail Teterin writes:

 MT>  Max N. Boyarov:
 >>       -f      The -f option causes tail to not stop when end of file is
 >>              reached, but rather to wait for additional data to be appended
 >> to the input.  The -f option is ignored if the standard input is a pipe,
 >> but not if it is a FIFO.

 MT> Josh Tolbert:
 >> Cause the -f option to tail doesn't work that way. -f always waits for more
 >> input.

 MT> I know very well about -f waiting for more *input*. What puzzles me, is that 
 MT> tail does not quit, when its *output* is closed.

 MT> James Harrison:
 >> Is there a reason you want the -f flag?

 MT> Yes, I want awk to be processing the lines, which are appended to the file, 
 MT> until it finds, what it is looking for, and exits. I expect tail to go away, 
 MT> when its stdout is closed, but it does not.

 >> tail -f holds on for dear life until a ctrl-c happens. IT HAS A DEATH
 >> GRIP!

 MT> This seems like a bug to me... It should hold on to its input file(s), but 
 MT> exit peacefully, when its stdout closes. No?

 tail -f /tmp/foo | awk '{print "$1"}
 
  tail write to pipe (reader wait data)   (2) 
  reader get data (2a) and exit (2b). action (3) from another console
  tail write data to pipe again.   action (4) from another console
  tail get SIGPIPE
  tail exit

 try to test your script with anoter file and add somthing to it

1) cons1$ touch /tmp/test
2)  cons1$ tail -f /tmp/test | awk '{print "Line: " $1 ;  exit(0)}END{print "Bye"}'
2a)  Line: Line1
2b)  Bye

3) cons2$  echo Line1 >> /tmp/test
4)  cons2$  echo Line2 >> /tmp/test
 
-- 
Max N. Boyarov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20071220/8b3ace12/attachment.pgp


More information about the freebsd-questions mailing list