* code 'paraphrased' for simplicity *
Hi all,
I have a script which goes to a subroutine. Within the subroutine, there
exists:
$pid = fork;
push(@pids, $pid);
unless ($pid)
{
my $var = new Object;
if (not $var->method_that_evokes_a_child()) {Exit;}
exit 2;
}
where the Exit subroutine exits with a number other than 2. The parent
process (before this subroutine is called), does a
$foo = waitpid $pids[$count], &WNOHANG;
and handles each child's return value.
The problem I am having:
CHILD_ERROR (or $?) on the outside of the subroutine is using the value from
the child-evoking-method, ignoring the exit code I am giving. For example,
if method_that_evokes_a_child exits with '1', the main parent gets '1' from
its child, rather than '2' (the argument passed to 'exit()') if method was
successful.
So, perhaps I'm confused with how the final "exit" of a child behaves with
regard to $?. If I don't call the child-evoking method, the original parent
gets the "exit" code of the child. I want this to be the case even when I
call the child-evoking method. Why does it not do this, and how can I 'fix'
it?
If anyone understands what I'm trying to explain, any help would be
appreciated. Thanks!
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>