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 );