logoalt Hacker News

brabeltoday at 5:53 PM2 repliesview on HN

Wouldn’t the seq process keep writing to output until the output buffer of the pipe got full and then the next write would block and seq would just pause waiting for the write call to unblock? Or my understanding of piping is incorrect?


Replies

syncsynchalttoday at 7:19 PM

What you've said is correct.

The slide says something like "run the command `seq 2 10000000 | less` and check `ps`, notice that `seq` isn't running". But that isn't how the processes will behave, `seq` will continue running (albeit blocked) until `less` is dead or closes the pipe.

js2today at 6:37 PM

Your understanding is correct. `seq` blocks when the pipe is full and is killed with SIGPIPE after `less` quits, closing the pipe.