in reply to Re^2: Parallel::ForkManager run_on_finish Canot get Exit Code of Child process
in thread Parallel::ForkManager run_on_finish Canot get Exit Code of Child process

I don't believe that run_on_exit didn't provide the exit code. Maybe you meant it was zero?

If the exit code is zero, then you're still not setting it to something other than zero. It's hard to tell what you're doing wrong if you don't show me what you did. What value did you pass to exit?

Replies are listed 'Best First'.
Re^4: Parallel::ForkManager run_on_finish Canot get Exit Code of Child process
by anshumangoyal (Scribe) on Dec 02, 2011 at 09:44 UTC
    This is what I did:
    sub RunChild { if (defined $proxy) { $ENV{http_proxy}="$proxy"; } $logFile = $logDir."/header_".$call; `curl -o /dev/null -m 222 \"$Link\" 2>> $logFile`; my $curlResult = `echo $?`; chomp($curlResult); if ($curlResult != 0) { exit($curlResult); } }

      First,

      my $curlResult = `echo $?`; chomp($curlResult);
      is the same thing as
      my $curlResult = $?;

      Second, $? doesn't contain the exit code. Well, not just the exit code. See its documentation.

      First,

      my $curlResult = `echo $?`; chomp($curlResult);
      is the same thing as
      my $curlResult = $?;

      Second, $? doesn't contain the exit code. Well, not just the exit code. See its documentation.

Re^4: Parallel::ForkManager run_on_finish Canot get Exit Code of Child process
by anshumangoyal (Scribe) on Dec 02, 2011 at 09:53 UTC
    Then how to get it. Please elaborate? I am badly stuck in this.
      I pointed you to documentation the states the following:
      $? == -1: Error launching child (See $! for cause) $? & 0x7F: Child died from this signal if non-zero $? >> 8: Child's exit code
      Why are you badly stuck? Did you see my response? Let P::FM do the work of getting the exit status. Also, in run_on_finish(), you are checking for core dump, and the exit code, but not the signal, if any. Why not check that also?