Force exit of processes on SIGTERM with 5 second clean-shutdown grace period

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1116 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-04-18 16:12:52 +00:00
parent 5f129d3107
commit d6400134ea

View File

@ -375,7 +375,12 @@ unless ($foreground) {
daemonize;
}
$SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) {} };
$SIG{TERM} = $SIG{INT} = sub { printf("Asked to quit...\n"); $quit++ };
$SIG{TERM} = $SIG{INT} = sub {
printf("Asked to quit...\n");
$quit++;
$SIG{ALRM} = sub { die "Did not close out in time for 5 second grace period"; };
alarm(5);
};
my $pid = xCAT::Utils->xfork;
defined $pid or die "Unable to fork for UDP/TCP";