Retrieving command exit code with open3
- From: "Ryan" <rplzqx402@xxxxxxxxxxxxxx>
- Date: 5 Dec 2005 12:58:41 -0800
I'm using code similar to the following to run a command and grab the
output from both STDOUT and STDERR separately:
local (*IN, *OUT, *ERR);
my $pid = IPC::Open3::open3(*IN, *OUT, *ERR, $cmd, @args);
print IN join "\n", @input;
close IN;
my @out = <OUT>;
my @err = <ERR>;
close OUT;
close ERR;
waitpid $pid, 0;
print "exit: $?\n"
Most of the time this works, but occasionally waitpid will return -1
and $? will also be set to -1 meaning that there is no child process.
Presumably the child exited before my call to waitpid.
What can I do to reliably grab the exit code?
Thanks,
-Ryan
.
- Follow-Ups:
- Re: Retrieving command exit code with open3
- From: xhoster
- Re: Retrieving command exit code with open3
- Prev by Date: Re: Howto get return code from a extern program?
- Next by Date: Re: unicode (hebrew) regexp search for new line headaches
- Previous by thread: Equality operators
- Next by thread: Re: Retrieving command exit code with open3
- Index(es):
Relevant Pages
|