At Fri, 14 Dec 2001 22:27:39 +0900,
Thom Harp <thomharp / charter.net> wrote:
> If the command given to IO#popen is invalid, ruby prints "command not found:
> ...." to stderr and exits. Wouldn't the Ruby way be to raise an exception?  The
> exec system call used in the implementation (at least for UN*X) can set errno
> to any number of useful values that I might like to know about in my script.
> Granted this is made more complicated by the fact that errno value would have
> to propagated back from a forked child, but we're sophisticated, we can handle
> that, right?

No, the message is emitted by forked child process.  You can
see;

  $ ruby -e 'p IO.popen("no-such-command")'
  -e:1: command not found: no-such-command
  #<IO:0x402c22f8>

Ignoring the child died, the parent process goes on.  Of
course, reading from the IO returns nil and writing causes an
exception Errno::EPIPE, however, there's no way for the parent
to know whether the child died before exec or successfully
exec'ed and the command exited.


BTW, once I wrote a patch that the parent waits until the child
reports the failure or execs.  Do you like it?


Nobu Nakada