as far as i understand your code, it tries to restart itself after the occurrence of any of the trapped signals. obviously this will run into an endless loop. apart from this i wonder whether you always know, in which of the several processes you create you're actually being in. you might get a cleaner and thus less error prone code if you switch from fork'ing to threads. because then everything will be part of one process, you'll be able to install common hooks for all signals - and besides you will have a simple means of generating log messages, which will probably help you find all the other things that aren't working as you expect them to do. e.g.:
#!/usr/bin/perl -w use strict; [...] # use whatever else use threads; use threads::shared; use Thread::Queue; [...] sub logger; our ($logs, $logger); $logs = Thread::Queue->new; $logger = threads->new(\&logger, "/path/to/logfile"); our $DEBUG : shared = 1; # care for signals: $SIG{INT} = $SIG{QUIT} = $SIG{CONT} = $SIG{STOP} = $SIG{TSTP} = $SIG{CHLD} = $SIG{TRAP} = $SIG{USR1} = $SIG{TTIN} = $SIG{TTOU} = $SIG{VTALRM} = $SIG{ALRM} = \&sig_ignore; $SIG{PIPE} = \&sig_pipe; $SIG{BUS} = $SIG{ILL} = $SIG{SEGV} = $SIG{FPE} = 'DEFAULT'; $SIG{HUP} = $SIG{ABRT} = $SIG{TERM} = $SIG{KILL} = \&sig_handler; $SIG{__WARN__} = $SIG{__DIE__} = sub { $logs->enqueue(shift) }; # now install all the other threads you want to run. # everything they have to do in case something goes wrong, # will be to simply warn() or die() - roughly told. # hence the logger finction is quite simple: sub logger { my $logfile = shift; open LOG, ">>$logfile" || die $!; while (my $msg = $logs->dequeue) { my $line = "[".localtime(time)."] $msg"; chomp $line; print LOG "$line\n"; flush LOG if $DEBUG; } close LOG; } [...] sub sig_ignore { return unless @_; $logs->enqueue("Silently ignoring signal ".shift); } sub sig_pipe { return unless @_; my $warn = "Caught signal ".shift().", "; # append more information to the warning message # if necessary $logs->enqueue($warn); } # the sig_handler() function has to carefully wait for all # threads to terminate properly and then simply exit - # which means again that there is only one process # to care for: sub sig_handler { return unless @_; $logs->enqueue(undef); $logger->join; [...] exit 0; }
these were very short excerpts from a daemon that i once wrote and which has now been running for years. without their context the lines may look rather obfuscating at the first glance, but i think that after a lecture on perldoc perlthrtut you will understand what they're intending.

hope i could be some sort of helpful
regards
--------------------------------
masses are the opiate for religion.

In reply to Re: getting a posix daemon and a web server to work together by TOD
in thread getting a posix daemon and a web server to work together by Hardy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.