Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!crdgw1!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Return values in pipelines Message-ID: <7378@star.cs.vu.nl> Date: 24 Aug 90 15:30:48 GMT References: <1990Aug22.211057.19850@agate.berkeley.edu> <7372@star.cs.vu.nl> <1990Aug23.215612.12422@iwarp.intel.com> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 36 In article <1990Aug23.215612.12422@iwarp.intel.com>, merlyn@iwarp.intel.com (Randal Schwartz) writes: )In article <7372@star.cs.vu.nl>, maart@cs (Maarten Litmaath) writes: ^^ Still broken software, Randal? )| In article <1990Aug22.211057.19850@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)