Show
Ignore:
Timestamp:
04/23/10 20:07:15 (5 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1272053235 +0000
git-parent:

[d1526ca817ef305f15a4f6418c2699bee9663f51]

git-author:
Mark Harrison <mark@omniti.com> 1272053235 +0000
Message:

Fix for a crash when run_command tries to run a non-existent command

When a child process exits (as is the case in run_command), the DESTROY method
of Resmon::Status gets called, and lots of bad things happen (web server is
killed, shared memory gets released). This commit adds a guard to make sure we
only do these if it is the main process that exits.

git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@315 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Status.pm

    r9b06619 r0cbd6e9  
    364364    $self->{http_ip} = $ip; 
    365365 
     366    $self->{parent_pid} = $$; 
    366367    $self->{child} = fork(); 
    367368    if($self->{child} == 0) { 
     
    504505sub DESTROY { 
    505506    my $self = shift; 
     507    # Make sure we're really the parent process 
     508    return if ($self->{parent_pid} != $$); 
    506509    my $child = $self->{child}; 
    507     if($child) { 
     510    if ($child) { 
    508511        kill 15, $child; 
    509512        sleep 1;