Skip Menu |

This queue is for tickets about the reaper CPAN distribution.

Report information
The Basics
Id: 29701
Status: open
Priority: 0/
Queue: reaper

People
Owner: Nobody in particular
Requestors: jonathon.eastman [...] wellpoint.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.00
Fixed in: 1.00



Subject: reaper doesn't work with waitpid function
I’ve been using th reaper perl modules to get the exit status for a forked exec call. It works as long as I don’t use the waitpid function. I'm not sure if this a bug or end-user ignorance, but is there a way around this? I'm on AIX 5.3 Using Perl 5.8.8 here's my code, if i take out my waitpid function and put a sleep in for the expected run-time of t1.pl, it works: use Reaper qw( reaper reapPid pidStatus ); { my $pid = fork; if ( $pid == 0 ) { # child exec "perl t1.pl"; } reapPid ( $pid ); waitpid($pid,0); if ( defined(my $exit = pidStatus($pid)) ) { print "CHILD OK\n"; } else { print "NOT OK\n"; } }
Subject: Re: [rt.cpan.org #29701] reaper doesn't work with waitpid function
Date: Mon, 01 Oct 2007 21:37:01 -0600
To: bug-reaper [...] rt.cpan.org
From: Jeremy Slade <jeremy [...] jkslade.net>
Reaper is intended for situations where the child can exit at any (unknown) time -- e.g. when you aren't specifically waiting for it. What happens with waitpid() is the waitpid() waits until the process is done, and gets the exit status from the kernel (stored in $?). So some time later when Reaper also calls waitpid(), the status has already been retrieved so it's no longer available... Calling waitpid() yourself is really not compatible with Reaper. If you want to waitpid() for the process yourself, the exit status is available immediately after waitpid() returns as $? waitpid($pid,0); my $exit = $?; if ( $exit ) { # non-zero exit status... } else { # exit = 0, child ok } Jeremy Jonathon Eastman via RT wrote: Show quoted text
> Mon Oct 01 18:57:09 2007: Request 29701 was acted upon. > Transaction: Ticket created by slackeast > Queue: reaper > Subject: reaper doesn't work with waitpid function > Broken in: 1.00 > Severity: Normal > Owner: Nobody > Requestors: jonathon.eastman@wellpoint.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=29701 > > > > I’ve been using th reaper perl modules to get the exit status for a > forked exec call. It works as long as I don’t use the waitpid > function. I'm not sure if this a bug or end-user ignorance, but is > there a way around this? > > I'm on AIX 5.3 > Using Perl 5.8.8 > > here's my code, if i take out my waitpid function and put a sleep in for > the expected run-time of t1.pl, it works: > > use Reaper qw( reaper reapPid pidStatus ); > { > my $pid = fork; > if ( $pid == 0 ) { # child > exec "perl t1.pl"; > } > reapPid ( $pid ); > > waitpid($pid,0); > > if ( defined(my $exit = pidStatus($pid)) ) { > print "CHILD OK\n"; > } > else { > print "NOT OK\n"; > } > }
Subject: RE: [rt.cpan.org #29701] reaper doesn't work with waitpid function
Date: Tue, 2 Oct 2007 11:10:43 -0700
To: <bug-reaper [...] rt.cpan.org>
From: "Eastman, Jonathon" <Jonathon.Eastman [...] wellpoint.com>
Thanks for your quick response. I used the $? Predefined variable and it works well on my windows computer. However, it doesn't work on AIX-5.3. It returns only a -1. Must be an AIX POSIX compliance issue. So I just created my own waitpid function and in combination with reaper, it works great. Thanks for all your help! Jonathon Eastman Show quoted text
-----Original Message----- From: Jeremy Slade via RT [mailto:bug-reaper@rt.cpan.org] Sent: Monday, October 01, 2007 8:38 PM To: Eastman, Jonathon Subject: Re: [rt.cpan.org #29701] reaper doesn't work with waitpid function <URL: http://rt.cpan.org/Ticket/Display.html?id=29701 > Reaper is intended for situations where the child can exit at any (unknown) time -- e.g. when you aren't specifically waiting for it. What happens with waitpid() is the waitpid() waits until the process is done, and gets the exit status from the kernel (stored in $?). So some time later when Reaper also calls waitpid(), the status has already been retrieved so it's no longer available... Calling waitpid() yourself is really not compatible with Reaper. If you want to waitpid() for the process yourself, the exit status is available immediately after waitpid() returns as $? waitpid($pid,0); my $exit = $?; if ( $exit ) { # non-zero exit status... } else { # exit = 0, child ok } Jeremy Jonathon Eastman via RT wrote:
> Mon Oct 01 18:57:09 2007: Request 29701 was acted upon. > Transaction: Ticket created by slackeast > Queue: reaper > Subject: reaper doesn't work with waitpid function > Broken in: 1.00 > Severity: Normal > Owner: Nobody > Requestors: jonathon.eastman@wellpoint.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=29701 > > > > I've been using th reaper perl modules to get the exit status for a > forked exec call. It works as long as I don't use the waitpid > function. I'm not sure if this a bug or end-user ignorance, but is > there a way around this? > > I'm on AIX 5.3 > Using Perl 5.8.8 > > here's my code, if i take out my waitpid function and put a sleep in
for
> the expected run-time of t1.pl, it works: > > use Reaper qw( reaper reapPid pidStatus ); > { > my $pid = fork; > if ( $pid == 0 ) { # child > exec "perl t1.pl"; > } > reapPid ( $pid ); > > waitpid($pid,0); > > if ( defined(my $exit = pidStatus($pid)) ) { > print "CHILD OK\n"; > } > else { > print "NOT OK\n"; > } > }
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information or otherwise protected by law. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.