For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > July 2004 > Looking for portable signal handling to implement Server Daemon









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Looking for portable signal handling to implement Server Daemon
Joachim Schrod

2004-07-28, 8:56 pm

Hello,

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
POSIX::sigaction()?

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...

Cheers,
Joachim

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod Email: jschrod@acm.org
Roedermark, Germany
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com