Subject: | pid_running should always return false if $self->pid is 0 |
in do_stop in Daemon/Control.pm the following code:
if ( $self->pid && $self->pid_running ) {
foreach my $signal ( qw(TERM TERM INT KILL) ) {
kill $signal => $self->pid;
sleep 1;
last unless $self->pid_running;
}
doesn't prevent a pid of 0 being sent signals, which then kill the current process. If pid_running is changed to return false if $self->pid is 0 then this is prevented, something like this:
sub pid_running {
my ( $self ) = @_;
$self->read_pid;
return 0 if $self->pid == 0;
return 0 unless kill 0, $self->pid;
#return kill 0, shift->pid;
if ( $self->pid && $self->pid_running ) {
foreach my $signal ( qw(TERM TERM INT KILL) ) {
kill $signal => $self->pid;
sleep 1;
last unless $self->pid_running;
}
doesn't prevent a pid of 0 being sent signals, which then kill the current process. If pid_running is changed to return false if $self->pid is 0 then this is prevented, something like this:
sub pid_running {
my ( $self ) = @_;
$self->read_pid;
return 0 if $self->pid == 0;
return 0 unless kill 0, $self->pid;
#return kill 0, shift->pid;