Hi -

I have installed the signal handler as you advised me. but still the exec call terminates the process and i don't know why.

Here is the code:
#!/usr/bin/perl -w use strict; use Socket; use Carp; use MTS; use MTS qw(prepare_transaction); use Proc::Daemon; use File::Temp qw(tempfile); use Data::Dumper; use Logger::Syslog; use JSON; use File::Find; use File::Basename; use Cwd 'realpath'; use POSIX (); #use FindBin(); use File::Spec::Functions qw(rel2abs catfile); no warnings 'File::Find'; my $SELF = rel2abs($0); my @argv = @ARGV; # Daemonizing Proc::Daemon::Init unless defined($ENV{"DEBUG"}); use vars qw($mts $qtime $qattr $qsender $qempty $qxtra $qend @template + $PORT @rcpts $pid $lock_dir @children $cfg $CONFIG_FILE); $CONFIG_FILE = '/etc/mts/mts.conf'; # # Forward Declarations # sub spawn; sub _dispatcher; sub _check_spam; sub _process_request; sub _build_msg; sub _enqueue_messages; sub _prepare_message; sub _notify; sub _signal_handler; sub _recover_transactions; sub _lock_maildrop_dir; sub _read_config; sub _reload_config; $SIG{CHLD} = \&REAPER; $SIG{HUP} = \&sigHUP_handler; #$SIG{__DIE__} = 'IGNORE'; $SIG{ABRT} = \&_signal_handler; $SIG{TERM} = \&_signal_handler; $SIG{INT} = \&_signal_handler; _read_config; #print Dumper $cfg; sub sigHUP_handler { #_reload_config; debug("Restarting daemon with: \$SELF=$SELF and \@argv=@argv "); exec($SELF,@argv); } # POSIX unmasks the sigprocmask properly #my $sigset = POSIX::SigSet->new(); #my $action = POSIX::SigAction->new('sigHUP_handler', $sigset, &POSIX: +:SA_NODEFER); #POSIX::sigaction(&POSIX::SIGHUP, $action); #$action = POSIX::SigAction->new('_signal_handler', $sigset, &POSIX::S +A_NODEFER); #POSIX::sigaction(&POSIX::SIGTERM, $action); #POSIX::sigaction(&POSIX::SIGINT, $action); #POSIX::sigaction(&POSIX::SIGABRT, $action);

pay attention to the commented code block which uses POSIX. This does the same problem too

10x

In reply to Re^2: Perl Daemons and SIGHUP by explodec14
in thread Perl Daemons and SIGHUP by explodec14

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.