Looking for portable signal handling to implement Server Daemon

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I want to write a server daemon class, from the concept similar to
Net::Daemon -- i.e., a framework where the actual server inherits my
class and implements several methods like handle_data(), reconfig(),
terminate(), get_data(), etc. I cannot use Net::Daemon as I need that
for arbitrary data sources (e.g., named pipes), and not just for network
services. Proc::Daemon doesn't target this demand either.

For the implementation I need portable signal handling that interrupts
system calls, in particular I/O functions. E.g., I want read (or
sysread) to terminate on SIGTERM, setting $! to EINTR. (Termination of
the server shall not wait until the next data arrives. Similar arguments
exist for SIGHUP.)

Does there exist a CPAN module that provides such signal behavior in a
portable way? (I won't complain if somebody calls me dumb and points to
a ready made server daemon module, btw.) Is Sys::SigAction the way to
go? I have read the man page, but couldn't answer that question, and
decided to ask here before I write test scripts myself. ;-)

I've got some experience with POSIX sigaction() in C, btw; though it's
some years ago. But that experience doesn't seem to be enough -- I
couldn't create a quick script with POSIX::sigaction() within 15
minutes. :-( Therefore, if Sys::SigAction is not the way to go and if
there's no other CPAN module, where can I find usage examples of

Btw, I am aware that signal semantics changed in Perl 5.8.2. In the end,
I need to run appropriate code in 5.6.1, 5.8.0, 5.8.1, and 5.8.3.
Starting now, I would be glad for any code that I can reuse in whatever
Perl version...


Joachim Schrod                Email: jschrod@acm.org
Roedermark, Germany

Site Timeline