From c779a9fb05cbc8676cb9cd9644d29d0e0d6ef851 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 21 Apr 2008 15:37:39 +0000 Subject: [PATCH] -Fix problem with server portion of ctrl-c bug -Have blade plugin propogate ctrl-c induced abort to mpa processes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1134 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/blade.pm | 11 ++++++++++- xCAT-server-2.0/sbin/xcatd | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/blade.pm b/xCAT-server-2.0/lib/xcat/plugins/blade.pm index 47dd67da4..2eb951c2f 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/blade.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/blade.pm @@ -9,6 +9,7 @@ use xCAT::Usage; use IO::Socket; use SNMP; use strict; +my %mm_comm_pids; use XML::Simple; if ($^O =~ /^linux/i) { @@ -1276,6 +1277,13 @@ sub preprocess_request { sub process_request { + $SIG{INT} = $SIG{TERM} = sub { + foreach (keys %mm_comm_pids) { + kill 2, $_; + } + exit 0; + }; + my $request = shift; my $callback = shift; my $doreq = shift; @@ -1384,7 +1392,7 @@ sub process_request { my $children = 0; - $SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) { $children--; } }; + $SIG{CHLD} = sub { my $cpid; while ($cpid = waitpid(-1, WNOHANG) > 0) { delete $mm_comm_pids{$cpid}; $children--; } }; my $inputs = new IO::Select;; foreach my $info (@$moreinfo) { $info=~/^\[(.*)\]\[(.*)\]\[(.*)\]/; @@ -1424,6 +1432,7 @@ sub process_request { dompa($pfd,$mpa,\%mpahash,$command,-args=>\@exargs); exit(0); } + $mm_comm_pids{$cpid} = 1; close ($pfd); $sub_fds->add($cfd); } diff --git a/xCAT-server-2.0/sbin/xcatd b/xCAT-server-2.0/sbin/xcatd index f1519e15b..43ad1cb9b 100755 --- a/xCAT-server-2.0/sbin/xcatd +++ b/xCAT-server-2.0/sbin/xcatd @@ -784,7 +784,7 @@ sub dispatch_request { } my $childrn=0; - $SIG{CHLD} = sub {my $cpid; while ($cpid =waitpid(-1, WNOHANG) > 0) { undef $dispatched_children{$cpid}; $childrn--; } }; + $SIG{CHLD} = sub {my $cpid; while ($cpid =waitpid(-1, WNOHANG) > 0) { delete $dispatched_children{$cpid}; $childrn--; } }; foreach (@{$reqs}) { my $pfd; my $parfd; #use a private variable so it won't trounce itself recursively