SPUG: Signals: Best Practices?
cos at indeterminate.net
Fri Nov 3 13:29:04 PST 2006
On Wed, 18 Oct 2006, Tim Maher wrote:
> Clarifying the subject, and focusing more, in the hope of sparking
> some discussion.
> On Wed, Oct 18, 2006 at 11:27:44AM -0700, Tim Maher wrote:
> > SPUGsters,
> > Using Sys::SigAction for setting all signal handlers and timeouts
> > would seem to have the potential for making these tools more reliable
> > and portable, but .. I wonder how intelligent this module
> > really is. ...
> > Can somebody offer some guidelines, or "Best Practices", or actual
> > documentation, on how to use Perl signals reliably and portably with
> > the 5.8.* versions of Perl?
I can't vouch for the module's intelligence. It seems like the approach
goes beyond intelligent-space ("I know it works") and faith-space ("I hope
it works") to caveat space ("CYA").
I looked at Sys::SigAction, POSIX, and perlipc on CPAN. I don't claim
expertise on the topic, but researching skills help a bit (and might
Sys::SigAction: "Perl 5.8.0 and later versions implements 'safe' signal
handling on platforms which support the POSIX sigaction() function."
POSIX: "Furthermore, some evil vendors will claim 1003.1 compliance, but
in fact are not so: they will not pass the PCTS (POSIX Compliance Test
And some ports don't have 1003.1 compliance - I can't image that Windows
3.1 does, but I could be wrong.
perlipc: "Because Perl's signal mechanism is currently based on the
signal(3) function from the C library, you may sometimes be so
misfortunate as to run on systems where that function is 'broken', that
is, it behaves in the old unreliable SysV way rather than the newer, more
reasonable BSD and POSIX fashion."
and perlipc again: "For more complex signal handling, you might see the
standard POSIX module. Lamentably, this is almost entirely undocumented,
but the t/lib/posix.t file from the Perl source distribution has some
examples in it."
I think it would help focus the discussion further if you if you indicated
on what platforms you want the scripts to function, on what platforms you
expect they will be used, and on what platforms you think they have a good
chance of running.
Last, the Sys::SigAction source at least checks whether the OS supports
signals; warns if you are using < 5.8.2; and does a couple of other
cautious things depending on your perl version.
More information about the spug-list