Return values in pipelines

Maarten Litmaath maart at cs.vu.nl
Sat Aug 25 01:30:48 AEST 1990


In article <1990Aug23.215612.12422 at iwarp.intel.com>,
	merlyn at iwarp.intel.com (Randal Schwartz) writes:
)In article <7372 at star.cs.vu.nl>, maart at cs (Maarten Litmaath) writes:
					^^
					Still broken software, Randal?

)| In article <1990Aug22.211057.19850 at agate.berkeley.edu>,
)| )	      How can I detect if something went wrong on the previous
)| )commands in the pipeline (prog2, prog3)?
)| 
)| You can do something like this:
)[program using fd 3 and /bin/sh fd duping deleted]
)
)Hmm.  Similar to what I was going to do, except that I would have used
)temp files (remember... a temp file is just a pipe with an attitude
)and a strong will to live).

Yes, and that's why I _hate_ 'em!  You can always get screwed if someone
else decides to ``rm /tmp/*''...
Furthermore pipes have nice blocking & signaling semantics.

)...
)With temp files, you won't get a race condition if both processes
)decide to exit at *exactly* the same time (rare, but it'll happen!).

There is _no_ race condition with my solution, as each of the write()s
to the pipe is atomic, because the number of bytes is smaller than
4096 (<= PIPESIZE, or whatever it's called).

Only the _order_ in which the various messages arrive is undetermined.

BTW, I expected a Perl solution from you...  :-)
Larry?
--
        "[Your C code] seems about as portable as the Rock of Gibraltar."
                                 (Wayne Throop)



More information about the Comp.unix.questions mailing list