Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Need $? for open() Keywords: new feature request Message-ID: <7605@jpl-devvax.JPL.NASA.GOV> Date: 29 Mar 90 22:49:28 GMT References: <23449@pasteur.Berkeley.EDU> <100906@convex.convex.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 44 In article <100906@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: : It's known that opening pipes to non-existent programs doesn't : usually trigger useful error diagnostics. In particular, while : writing on a badly-opened output pipe will (eventually) trigger a : SIGPIPE (which you can look for), reading from a badly-opened input : pipe just gets you EOF. : : A possible work-around for the bad input pipe follows: : : $kid = open (PIPE, "bogus_command |"); # really should check $kid != 0 : (kill 0, $kid) || die "bogus_command failed"; : : : This works fine if bogus_command doesn't have shell metas in it, but : if it does, the shell may well not have exited before the kill 0. : : You can introduce a delay, : : $kid = open (PIPE, "bogus_command ) { ... If you do want the shell to run, then you can probably do something like open(PIPE, "bogus command || kill -PIPE $$ |") Larry