From 4734f2311a73c7e49d3950ecb24d617c00fab479 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Jun 2001 17:10:22 +0000 Subject: [PATCH] Smarter HUP handling that handles restarting with both --debug and --nodaemonize options. Before, --nodaemonize wasn't being passed to the re-execed spong-*. --- src/spong-client.pl | 7 ++++--- src/spong-network.pl | 7 +++++-- src/spong-server.pl | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/spong-client.pl b/src/spong-client.pl index 89c84bd..11a6c8c 100755 --- a/src/spong-client.pl +++ b/src/spong-client.pl @@ -12,7 +12,7 @@ # History: # (1) Ported bb-local.sh script to perl. (Ed Hill Feb 26, 1997) # -# $Id: spong-client.pl,v 1.18 2001/06/19 21:24:32 supermathie Exp $ +# $Id: spong-client.pl,v 1.19 2001/06/20 17:10:22 supermathie Exp $ use lib '@@LIBDIR@@'; @@ -244,8 +244,9 @@ sub hup_handler { &debug( "caught HUP signal, restarting..." ); unlink "$SPONGTMP/spong-client.pid" if -f "$SPONGTMP/spong-client.pid"; $SIG{$_[0]} = \&hup_handler; - if( $debug ) { exec $me, "--debug", $debug; } else { exec $me; } - exit(0); + if( $debug ) { push(@args, "--debug", $debug); } + if( $nodaemonize ) { push(@args, "--nodaemonize"); } + exec $me, @args or die "Couldn't exec $me after HUP"; } sub pipe_handler { diff --git a/src/spong-network.pl b/src/spong-network.pl index 847853e..e93d595 100755 --- a/src/spong-network.pl +++ b/src/spong-network.pl @@ -17,7 +17,7 @@ # (2) Converted checks to new plugin mechanism (Stephen Johnson May 28, 1999) # Added user-configurable escalation mechanism # -# $Id: spong-network.pl,v 1.38 2001/06/19 21:24:32 supermathie Exp $ +# $Id: spong-network.pl,v 1.39 2001/06/20 17:10:22 supermathie Exp $ use Carp; use lib "@@LIBDIR@@"; @@ -553,7 +553,10 @@ sub hup_handler { &debug( "caught HUP signal, restarting..." ); unlink "$SPONGTMP/spong-network.pid" if "$SPONGTMP/spong-network.pid"; alarm(0); - if( $debug ) { exec $me, "--debug", $debug; } else { exec $me; } + @args = ($me); + if( $debug ) { push(@args, "--debug", $debug); } + if( $nodaemonize ) { push(@args, "--nodaemonize"); } + exec $me, @args or die "Couldn't exec $me after HUP"; } sub pipe_handler { diff --git a/src/spong-server.pl b/src/spong-server.pl index 3c7a23b..303e88a 100755 --- a/src/spong-server.pl +++ b/src/spong-server.pl @@ -6,7 +6,7 @@ # There are one or more update processes that listen for status updates # from client programs. -# $Id: spong-server.pl,v 1.43 2001/06/19 21:28:02 supermathie Exp $ +# $Id: spong-server.pl,v 1.44 2001/06/20 17:10:22 supermathie Exp $ use lib "@@LIBDIR@@"; @@ -1408,7 +1408,9 @@ sub hup_handler { # kill QUIT,$bb_pid; waitpid($bb_pid,0); unlink "$SPONGTMP/spong-server.pid" if -f "$SPONGTMP/spong-server.pid"; close( SERVER ); - if( $debug ) { exec $me, "--debug", $debug; } else { exec $me; } + if( $debug ) { push(@args, "--debug", $debug); } + if( $nodaemonize ) { push(@args, "--nodaemonize"); } + exec $me, @args or die "Couldn't exec $me after HUP"; } # If the child process dies for some reason, then we restart it. -- 2.30.2