From 0a6dc4ad6e3bc684efdeebabeb4d173814b12c77 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 28 Jul 2009 07:56:43 +0000 Subject: [PATCH] kill child process if xcat command stopped by signal git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3884 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCboot.pm | 7 ++++++- perl-xCAT/xCAT/PPCmac.pm | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/PPCboot.pm b/perl-xCAT/xCAT/PPCboot.pm index 7a47861af..73a687537 100644 --- a/perl-xCAT/xCAT/PPCboot.pm +++ b/perl-xCAT/xCAT/PPCboot.pm @@ -219,7 +219,12 @@ sub do_rnetboot { ####################################### # Execute command ####################################### - if ( !open( OUTPUT, "$cmd 2>&1 |")) { + my $pid = open( OUTPUT, "$cmd 2>&1 |"); + $SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down + kill 9, $pid; + exit 0; + }; + if ( !$pid ) { return( [RC_ERROR,"$cmd fork error: $!"] ); } ####################################### diff --git a/perl-xCAT/xCAT/PPCmac.pm b/perl-xCAT/xCAT/PPCmac.pm index e61df1082..bed510398 100644 --- a/perl-xCAT/xCAT/PPCmac.pm +++ b/perl-xCAT/xCAT/PPCmac.pm @@ -294,9 +294,15 @@ sub do_getmacs { ####################################### # Execute command ####################################### - if ( !open( OUTPUT, "$cmd 2>&1 |")) { + my $pid = open( OUTPUT, "$cmd 2>&1 |"); + $SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down + kill 9, $pid; + exit 0; + }; + if ( !$pid ) { return( [RC_ERROR,"$cmd fork error: $!"] ); } + ####################################### # Get command output #######################################