Corrected pid going out of scope on stop.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@175 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2002-12-11 00:20:51 +00:00
parent 55950fdec1
commit b5a4d7927f
1 changed files with 5 additions and 4 deletions

View File

@ -198,13 +198,14 @@ if ( !connect( CLIENT, $saddr ) )
my $command = "$daemon ".join( ' ', @args );
my $process = $cmd_hash{$command};
my $cpid = $process->{pid};
if ( !$process )
{
dprint( "Can't find process with command of '$command'\n" );
return();
}
if ( !$pid_hash{$process->{pid}} )
if ( !$pid_hash{$cpid} )
{
dprint( "No process with command of '$command' is running\n" );
return();
@ -212,16 +213,16 @@ if ( !connect( CLIENT, $saddr ) )
print( "'$daemon ".join( ' ', @args )."' stopping at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
$process->{keepalive} = !$final;
kill( 'TERM', $process->{pid} );
kill( 'TERM', $cpid );
delete( $cmd_hash{$command} );
# Now check it has actually gone away, if not kill -9 it
my $count = 0;
while( kill( 0, $process->{pid} ) )
while( kill( 0, $cpid ) )
{
if ( $count++ > 5 )
{
kill( 'KILL', $process->{pid} );
kill( 'KILL', $cpid );
}
}
}