Bug 207 - Fixed (hopefully) undefed pid issue for restarting crashed processes.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1615 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-11-22 11:19:09 +00:00
parent 90360aa18c
commit 02f3ea1ac5
1 changed files with 7 additions and 10 deletions

View File

@ -217,11 +217,6 @@ if ( !connect( CLIENT, $saddr ) )
{ {
# It's not running, or at least it's not been started by us # It's not running, or at least it's not been started by us
$process = { daemon=>$daemon, args=>\@args, command=>$command, keepalive=>!undef }; $process = { daemon=>$daemon, args=>\@args, command=>$command, keepalive=>!undef };
# So check whether someone else has started it
#$ps_command = "ps -wh --user $> | grep '$command' | grep -v grep";
#$ps_array = preg_split( "/\s+/", exec( $ps_command ) );
#$pid = $ps_array[3];
#if ( $pid )
} }
elsif ( $process->{pid} && $pid_hash{$process->{pid}} ) elsif ( $process->{pid} && $pid_hash{$process->{pid}} )
{ {
@ -266,7 +261,6 @@ if ( !connect( CLIENT, $saddr ) )
foreach my $arg ( @args ) foreach my $arg ( @args )
{ {
# Detaint arguments, if they look ok # Detaint arguments, if they look ok
#if ( $arg =~ /^(-{0,2}[\w]+)/ )
if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ ) if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ )
{ {
push( @good_args, $1 ); push( @good_args, $1 );
@ -341,14 +335,17 @@ if ( !connect( CLIENT, $saddr ) )
$command .= ' '.join( ' ', ( @args ) ) if ( @args ); $command .= ' '.join( ' ', ( @args ) ) if ( @args );
my $process = $cmd_hash{$command}; my $process = $cmd_hash{$command};
if ( $process ) if ( $process )
{
if ( $process->{pid} )
{ {
my $cpid = $process->{pid}; my $cpid = $process->{pid};
if ( $pid_hash{$cpid} ) if ( defined($pid_hash{$cpid}) )
{ {
_stop( 0, $daemon, @args ); _stop( 0, $daemon, @args );
return; return;
} }
} }
}
start( $daemon, @args ); start( $daemon, @args );
} }
sub reaper sub reaper