RE: Perl Signal Handling (Red Hat AS 3)

[email protected] ("Oliver Rees") Mon, 25 Sep 2006 12:23:19 +0100
Newsgroups perl.loop
Message-ID <[email protected]>
Joshua,

Thank you for your reply.

Just to clarify, I have not tried to use the Event module yet. I am =
trying to ascertain whether the method I am currently using (with  =
$SIG{CHLD} set to the reaper function I listed) should be 100% reliable =
since perl 5.8.0, or whether there are any race conditions etc that =
might have a bearing.

If I am not using a reliable method, then I wondered whether Event would =
be better, and if so why.

The perl signal handling documentation that I have found to date does =
not explain the sporadic WEXITSTATUS($?)=3D255  WTERMSIG($?)=3D127 =
results that I have seen across a number of systems.=20

Regards,
Oliver

-----Original Message-----
From: Joshua N Pritikin [mailto:[email protected]]
Sent: 22 September 2006 18:28
To: Oliver Rees
Cc: [email protected]
Subject: Re: Perl Signal Handling (Red Hat AS 3)


On Fri, Sep 22, 2006 at 03:32:28PM +0100, Oliver Rees wrote:
> I have been looking at your Event module to see if it might solve a=20
> problem I am experiencing with signal handling using perl 5.8.0 on Red =

> Hat AS 3.
>=20
> I have a module which forks a number of processes and captures the=20
> exit codes via a handler defined for $SIG{CHLD}. I have listed the=20
> reaper handler below. 99% of the time it works fine - but every so=20
> often, a process exitcode is recorded as 255 and the signal that=20
> apparently terminated it as 127 - which I do not believe is accurate.=20
> I have restricted my waitpid() calls to specific process IDs.

Hrm, here's some info from the perl FAQ:

       Perl versions before 5.8 had in its C source code signal handlers =

which
       would catch the signal and possibly run a Perl function that you=20
had
       set in %SIG.  This violated the rules of signal handling at that=20
level
       causing perl to dump core. Since version 5.8.0, perl looks at=20
%SIG
       *after* the signal has been caught, rather than while it is being
       caught.

> Is there an obvious/common explanation for this behaviour? If so, how=20
> does the Event module handle it?

If the above is true, I don't think Event does it any less correctly=20
than perl.

This e-mail and any attachment is for authorised use by the intended =
recipient(s) only. It may contain proprietary material, confidential =
information and/or be subject to legal privilege. It should not be =
copied, disclosed to, retained or used by, any other party. If you are =
not an intended recipient then please promptly delete this e-mail and =
any attachment and all copies and inform the sender. Thank you.