check every second for kill_timeout seconds if the daemon has terminated, rather than only checking at the end

This commit is contained in:
Karen Etheridge 2013-04-19 11:38:34 -07:00
parent 7e7e736ab8
commit e56baf1a88
2 changed files with 12 additions and 1 deletions

View file

@ -1,6 +1,9 @@
* create dir for pid_file if it does not exist
* fix uninitialized warning in error when exec fails
* 'stop' is now faster when kill_timeout is set to high values, by checking
every second if the daemon has terminated rather than waiting for the
full kill_timeout duration
0.001000 2013-02-26 SymKat <symkat@symkat.com>
* fixed a warning on "uninitialized value $called_with in substitution"

View file

@ -382,8 +382,16 @@ sub do_stop {
if ( $self->pid && $self->pid_running ) {
foreach my $signal ( qw(TERM TERM INT KILL) ) {
$self->trace( "Sending $signal signal to pid ", $self->pid, "..." );
kill $signal => $self->pid;
sleep $self->kill_timeout;
for (1..$self->kill_timeout)
{
# abort early if the process is now stopped
$self->trace('checking if pid ', $self->pid, ' is still running...');
last if not $self->pid_running;
sleep 1;
}
last unless $self->pid_running;
}
if ( $self->pid_running ) {