Looking for portable signal handling to implement Server Daemon

From: Joachim Schrod (jschrod_at_acm.org)
Date: 07/28/04

  • Next message: John W. Kennedy: "HTTP::TreeBuilder problems"
    Date: Wed, 28 Jul 2004 23:33:05 +0200
    
    

    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
    

  • Next message: John W. Kennedy: "HTTP::TreeBuilder problems"