Unix/Linux pipe behavior when reading process terminates before writing process
问题 I have this: $ ls -lh file -rw-r--r-- 1 ankur root 181M Sep 23 20:09 file $ head -6 file z abc abc abc abc abc $ cat file | grep -m 1 z z Question: Why is the cat command line in the last line not dying prematurely with SIGPIPE? I think this should happen because grep terminates in no time compared to cat file that cats 183MB of file. With reading process gone cat will try to write to a broken pipe and should die with SIGPIPE. Update: I ended up writing this: readstdin.c # include <unistd.h>