kill child process if xcat command stopped by signal

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3885 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
wanghuaz 2009-07-28 07:57:26 +00:00
parent 0a6dc4ad6e
commit 3e00fd6702
2 changed files with 19 additions and 13 deletions

View File

@ -214,7 +214,14 @@ sub process_command {
# Use the CHID signal to control the
#connection number of certain hcp
$SIG{CHLD} = sub { my $pid = 0; while (($pid = waitpid(-1, WNOHANG)) > 0)
{ $nodes->{$pid_owner{$pid}}{'runprocess'}--; $children--; } };
{ $nodes->{$pid_owner{$pid}}{'runprocess'}--; delete $pid_owner{$pid}; $children--; } };
$SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down
foreach (keys %pid_owner) {
kill 9, $_;
}
exit 0;
};
my $hasnode = 1;
while ($hasnode) {

View File

@ -1798,18 +1798,6 @@ proc Firmware_Dump { device_path phandle } {
}
}
#
# Signal handling stuff
#
trap {
global PROGRAM
set signal SIG[trap -name]
send_user "$PROGRAM: Received signal named '$signal'\n"
exit 3
} {INT HUP QUIT TERM}
#
@ -2081,6 +2069,17 @@ if [ catch { spawn $CONSOLEBIN $name -f } rsconole_pid ] {
set spawn_id_rconsole $spawn_id
nc_msg "$PROGRAM Status: spawn_id is $spawn_id\n"
#
# Signal handling stuff
#
trap {
global PROGRAM
set signal SIG[trap -name]
send_user "$PROGRAM: Received signal named '$signal'\n"
exec kill -KILL $spawn_id_rconsole $ssh_spawn_id
exit 3
} {INT HUP QUIT TERM}
set timeout 10
set pwd_sent 0
send_user "# Connecting to $name\n"