4 ms·
I am not sure what you are referring to, but the case where EPIPE is useful is incase you do something like: grep foo *.txt|head -n10 Here head will close
by sorbits 16y ago
I am not sure what you are referring to, but the case where EPIPE is useful is incase you do something like:
grep foo *.txt|head -n10
Here head will close its stdin after having read 10 lines. If grep writes more it will get the EPIPE error on write (which may indirectly be called by fflush).
This will also send the SIGPIPE signal which by default will kill the process, so grep is automatically terminated when no more output will be read from it.