Skip to content
Snippets Groups Projects
Commit 0cbd6e9c authored by Mark Harrison's avatar Mark Harrison
Browse files

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
parent d1526ca8
No related branches found
No related tags found
No related merge requests found
......@@ -363,6 +363,7 @@ sub serve_http_on {
$self->{http_port} = $port;
$self->{http_ip} = $ip;
$self->{parent_pid} = $$;
$self->{child} = fork();
if($self->{child} == 0) {
eval {
......@@ -503,8 +504,10 @@ sub close {
}
sub DESTROY {
my $self = shift;
# Make sure we're really the parent process
return if ($self->{parent_pid} != $$);
my $child = $self->{child};
if($child) {
if ($child) {
kill 15, $child;
sleep 1;
kill 9, $child if(kill 0, $child);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment