Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Proc::Simple - exit_status function returns -1

by atanug (Initiate)
on Jul 31, 2013 at 03:20 UTC ( #1047161=perlquestion: print w/ replies, xml ) Need Help??
atanug has asked for the wisdom of the Perl Monks concerning the following question:

I am using Proc::Simple module to fork 5 child processes. I polling the processes to check if the processes are still running or not. If poll function does not return anything, we are using the exit_status() function to check the exit status of the child process.

Sometime it is happening like, the exit_status function is returning -1 although I can see that the child process has done it's job. I am not getting this problem everyday. But every 5-7 days I can see in the log that one of the processes returned exit status as -1.

Please find the sample code snippet below.

my $proc = Proc::Simpler->new(); .... ... if($proc->poll){ # process is running } else { # process not running # call exit_status function # my $exit_status = $proc->exit_status(); # if exit_status returns true, log error for that process }

I want to know why it happens like sometime, the exit_status returns -1 and what should be done to resolve this issue?

Comment on Proc::Simple - exit_status function returns -1
Download Code
Re: Proc::Simple - exit_status function returns -1
by kcott (Abbot) on Jul 31, 2013 at 05:43 UTC

    G'day atanug,

    For future reference, questions about Perl should be posted in Seekers of Perl Wisdom and not in Perl Monks Discussion as you've done here. The first sentence of the Perl Monks Discussion page says:

    "This section is only for discussing issues pertaining to the PerlMonks web site." [original emphasis]

    [Update: I see that the thread has now been moved to SoPW following consideration.]

    On to your question. The Proc::Simple documentation says this about the exit_status() method:

    "Returns the exit status of the process as the $! variable indicates. If the process is still running, undef is returned."

    You can read about $! in perlvar - Error Variables.

    You'll need to look at the child processes you're forking for answers as to why they're exiting with -1.

    -- Ken

Re: Proc::Simple - exit_status function returns -1
by Perlbotics (Abbot) on Aug 01, 2013 at 18:43 UTC

    Please update your Module.

    I've also seen this bug and posted a patch here which was accepted and merged into version 1.28.

    Title: exit_status() can fail to return valid exit state after sufficently long runtime.

    Problem:
    A main process that runs sufficiently long might get an 'undef' or -1 form exit_status() instead of the real execution status.
    ...
    Analysis:
    If a Proc::Simple variable/object is DESTROYed while the associated Proc::Simple-process has already terminated, the PID is unnecessarily remembered in %DESTROYED for later reaping. If another process re-uses the PID (e.g. after the OS' PID wrap-around) the process is reaped by sub THE_REAPER and the execution state is lost since the %DESTROYED hash is checked before the %EXIT_STATUS hash there.
    ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1047161]
Approved by Arunbear
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2014-10-23 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls