in reply to I got IPC::Open3 to work!

1) The docs say "open3() does not wait for and reap the child process after it exits." You need to call waitpid on children that have completed.

2) Your return value are not the best. You return true when when open3 fails. You also return true on success.

3) I find it odd that you return undef when can_read returns a file handle you didn't give it. It shouldn't happen, so I would just ignore the error, since it shouldn't happen anyway. The safest way to handle it would be to do something like:

$err .= "Error from select: can_ready returned bad handle\n"; $select->remove($fh);

Replies are listed 'Best First'.
Re^2: I got IPC::Open3 to work!
by Tanktalus (Canon) on Jul 23, 2005 at 13:37 UTC

    Re #3 - I'm not sure I follow. If it shouldn't happen, it shouldn't matter how it's handled.

    Besides, I'd rather be woken up in the middle of the night by something that shouldn't happen but did, rather than mask the error by ignoring it. My house shouldn't catch fire, for example... ;-)

      Besides, I'd rather be woken up in the middle of the night by something that shouldn't happen but did, rather than mask the error by ignoring it.

      The dieing would be a better alternative then returning undef, which simply displaces the error to some other indeterminate location.

Re^2: I got IPC::Open3 to work!
by harleypig (Monk) on Jul 24, 2005 at 16:01 UTC

    The function only returns undef in that instance. I hate having some generic function die on me unexpectedly, especially when my boss calls me up shouting "You're stoopid program doesn't work!" I'd rather leave the choice to the calling program:

    callexternalpgm( parms ) or die "$!";
    or, more likely,
    callexternalpgm( parms ) or LogIt( "Error calling external program: $! +" );
    Harley J Pig