diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index 422e32acc..7f51acf40 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -282,7 +282,9 @@ if (ref($request) eq 'HASH') { # the request is an array, not pure XML $msg=$request; print $client $msg; } - $SIG{TERM} = $SIG{INT} = sub { send_request({abortcommand=>[1]},$client,$encode); exit 0; }; + # when receive TERM or INT (ctrl^c) from user, sleep 2s before exit to make + # sure the server (xcatd) has recevied 'abortcommand' command + $SIG{TERM} = $SIG{INT} = sub { send_request({abortcommand=>[1]},$client,$encode); sleep 2; exit 0; }; my $response; my $rsp; my $cleanexit=0; diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 840e6a7a4..95eea69f1 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -1861,6 +1861,10 @@ sub dispatch_request { } if ($onlyone and not ($_->{'_xcatdest'} and xCAT::NetworkUtils->thishostisnot($_->{'_xcatdest'}))) { $SIG{CHLD}='DEFAULT'; + + # make the plugin process exit directly instead of wait(), this is useful + # for the plugin process to exit successfully when it opened some shell subprocesses. + $SIG{TERM} = $SIG{INT} = 'DEFAULT'; "" =~ m/()/; #clear $1 that we may have sitting around if ($_->{'_xcatdelay'} and not ref $_->{'_xcatdelay'}) { sleep $_->{'_xcatdelay'}; } # Call the plugin to process the command request @@ -1955,6 +1959,9 @@ sub dispatch_request { } else { $$progname.=": locally executing"; $SIG{CHLD}='DEFAULT'; + # make the plugin process exit directly instead of wait(), this is useful + # for the plugin process to exit successfully when it opened some shell subprocesses. + $SIG{TERM} = $SIG{INT} = 'DEFAULT'; # Call the plugin to process the command request # rescanplugins request gets handled directly here in xcatd if ($_->{command}->[0] eq 'rescanplugins') {