check every second for kill_timeout seconds if the daemon has terminated, rather than only checking at the end
This commit is contained in:
parent
7e7e736ab8
commit
e56baf1a88
2 changed files with 12 additions and 1 deletions
3
Changes
3
Changes
|
@ -1,6 +1,9 @@
|
||||||
|
|
||||||
* create dir for pid_file if it does not exist
|
* create dir for pid_file if it does not exist
|
||||||
* fix uninitialized warning in error when exec fails
|
* 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>
|
0.001000 2013-02-26 SymKat <symkat@symkat.com>
|
||||||
* fixed a warning on "uninitialized value $called_with in substitution"
|
* fixed a warning on "uninitialized value $called_with in substitution"
|
||||||
|
|
|
@ -382,8 +382,16 @@ sub do_stop {
|
||||||
|
|
||||||
if ( $self->pid && $self->pid_running ) {
|
if ( $self->pid && $self->pid_running ) {
|
||||||
foreach my $signal ( qw(TERM TERM INT KILL) ) {
|
foreach my $signal ( qw(TERM TERM INT KILL) ) {
|
||||||
|
$self->trace( "Sending $signal signal to pid ", $self->pid, "..." );
|
||||||
kill $signal => $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;
|
last unless $self->pid_running;
|
||||||
}
|
}
|
||||||
if ( $self->pid_running ) {
|
if ( $self->pid_running ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue