From ac217055efca7728106d173a157db1a72515f062 Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 15 Jan 2003 10:05:50 +0000 Subject: [PATCH] Added kill_all function. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@325 e3e1d417-86f3-4887-817a-d78f3d33393f --- scripts/zmdc.pl.z | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/zmdc.pl.z b/scripts/zmdc.pl.z index 23a3476f6..008b9696b 100755 --- a/scripts/zmdc.pl.z +++ b/scripts/zmdc.pl.z @@ -130,6 +130,8 @@ if ( !connect( CLIENT, $saddr ) ) dprint( "Server starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" ); + kill_all(); + socket( SERVER, PF_UNIX, SOCK_STREAM, 0 ) or die( "Can't open socket: $!" ); unlink( DC_SOCK_FILE ); bind( SERVER, $saddr ) or die( "Can't bind: $!" ); @@ -330,12 +332,26 @@ if ( !connect( CLIENT, $saddr ) ) } } } + sub kill_all() + { + sleep( 1 ); + foreach my $daemon ( @daemons ) + { + qx( killall --quiet --signal -TERM $daemon ); + } + sleep( 1 ); + foreach my $daemon ( @daemons ) + { + qx( killall --quiet --signal -KILL $daemon ); + } + } sub shutdown_all() { foreach my $process ( values( %pid_hash ) ) { stop( $process->{daemon}, @{$process->{args}} ); } + kill_all(); dprint( "Server shutdown at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" ); unlink( DC_SOCK_FILE ); close( CLIENT );