dear lazy web ... (UNIX pipes)

Greg McCarroll greg at
Sat Apr 19 15:40:44 BST 2008

So, I thought I knew how pipes worked from a distant OS class at uni.

let say ...

    process_that_generates_output | grep something 

now i thought that grep would be started around the same time as the
first process and would grind through output when it had enough input
to work on, and from this dim distant OS class I remember we
implemented a special shared memory area in our own OS to do just
that (this was 14 years ago).

now today i wondered about,

    process_that_generates_output | grep something | head

wondering if when head had enough output to make it happy it would
terminate and that would propogate to grep and the first process.

and so i experimented timing the first process with and without head
as the final pipe, and in a very unscientific test it came out with
the same result.

so can someone either totally fulfill my laziness and explain why
(even if its 'your tests were wrong') or point me in the direction so i
can do my own figuring out.

(disclaimer: i'm being a little more lazy than usual as i thought it
 might be an interesting discussion topic)


More information about the mailing list