>>>>> "MT" == Mikhail Teterin writes:
      [...]
 MT> I'm sorry, this does not make sense to me. Starting with an empty
 MT> file, as you do in 1), /may/ make tail not notice, that awk went
 MT> away, because tail has nothing to write to stdout.

 MT> But /var/log/messages is not empty, and awk -- in my example -- would
 MT> exit upon seeing the very first line of its input (tail's output).
 MT> Yet tail fails to notice, that its subsequent output (starting with the
 MT> second line) is written to nowhere...

 MT> Why?
 Because nothing writeln to /var/log/messages
 
 $ sh -x /tmp/x.sh 
 + + tail -f /var/log/messages  
 awk {print "Exiting"; exit 0}
 Exiting
 + echo Exited
 Exited
 + exit 0

 after something writeln to /var/log/messages tail get SIGPIPE

open("/var/log/messages",O_RDONLY,0666)          = 3 (0x3)
fstat(3,{mode=-rw-r--r-- ,inode=141327,size=4997,blksize=4096}) = 0 (0x0)
mmap(0x0,4997,PROT_READ,MAP_SHARED,3,0x0)        = 672616448 (0x28175000)
Exiting
write(1,"Dec 20 11:59:04 solar kernel: da"...,1090) = 1090 (0x442)
fstat(3,{mode=-rw-r--r-- ,inode=141327,size=4997,blksize=4096}) = 0 (0x0)
lseek(3,0x0,SEEK_CUR)                            = 0 (0x0)
lseek(3,0x1000,SEEK_SET)                         = 4096 (0x1000)
read(3,"kernel: da1: 1.000MB/s transfers"...,4096) = 901 (0x385)
munmap(0x28175000,4997)                          = 0 (0x0)
read(3,0x28204000,4096)                          = 0 (0x0)
kqueue(0x28172d40,0x4,0xa,0x0,0x28201088,0x1)    = 4 (0x4)
fstatfs(0x3,0xbfbfe44c,0x2815fe98,0x28172d40,0x0,0x2806dee4) = 0 (0x0)
kevent(4,{0x3,EVFILT_READ,EV_ADD|EV_ENABLE|EV_CLEAR,0,0x0,0x0},1,0x0,0,{0.000000000})
 = 0 (0x0)
kevent(4,0x0,0,{0x3,EVFILT_READ,EV_CLEAR,0,0x3e,0x0},1,0x0) = 1 (0x1)
read(3,"Dec 20 12:06:27 solar su: BAD SU"...,4096) = 62 (0x3e)
fstat(1,{mode=p--------- ,inode=0,size=0,blksize=4096}) = 0 (0x0)
read(3,0x28204000,4096)                          = 0 (0x0)
write(1,"Dec 20 12:06:27 solar su: BAD SU"...,62) ERR#32 'Broken pipe'
SIGNAL 13 (SIGPIPE)

-- 
Max N. Boyarov

Attachment: pgp6Vf07VlDFE.pgp
Description: PGP signature

Reply via email to