develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #113028] [PATCH] Full example of REAPER in perlipc

Thread Previous
From:
Tony Cook via RT
Date:
June 24, 2013 02:21
Subject:
[perl #113028] [PATCH] Full example of REAPER in perlipc
Message ID:
rt-3.6.HEAD-2552-1372040474-186.113028-15-0@perl.org
On Fri May 25 06:08:13 2012, worldmind wrote:
> Птн. Май 25 04:21:50 2012, LeonT писал:
> > On Tue, May 22, 2012 at 5:05 PM, Leon Timmermans <fawaka@gmail.com> 
> > On second reading, that does not seem necessary. The process will
> > receive a sigchild under these circumstances, but waitpid will ignore
> > that status unless asked for it (using the WUNTRACED and WCONTINUE
> > options).
> 
> As I understand you say that we can skip WIFEXITED($?) and
> WIFSIGNALED($?) checking, but we will get STOP signal and process it
> like child exiting.
> Simple example in attached file:

I don't think this answers Leon's objection - waitpid() will only return
the child process id on a STOP if you supply WUNTRACED in options.

If you modify your code to check waitpid:

$SIG{CHLD} = sub {
  my $pid = waitpid(-1, WNOHANG);
  if ($pid > 0) {
    warn 'Get CHLD signal ', $pid;
  }
};

then you don't get the warning on a STOP.

That said, the waitpid() loop is required (which the cookbook doesn't
seem to use.)

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=113028

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About