Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Daemon-Control CPAN distribution.

Report information
The Basics
Id: 79355
Status: resolved
Priority: 0/
Queue: Daemon-Control

People
Owner: Nobody in particular
Requestors: james2vegas [...] aim.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



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;


Updated in the github repo, and will be releasing a new CPAN dist at or before Wednesday night. diff --git a/lib/Daemon/Control.pm b/lib/Daemon/Control.pm index 1c4f045..50cd6a6 100644 --- a/lib/Daemon/Control.pm +++ b/lib/Daemon/Control.pm @@ -241,8 +241,8 @@ sub pid_running { $self->read_pid; + return 0 unless $self->pid >= 1; return 0 unless kill 0, $self->pid; - #return kill 0, shift->pid; if ( $self->scan_name ) { open my $lf, "-|", "ps", "-p", $self->pid, "-o", "command=" On Sun Sep 02 08:04:39 2012, JWRIGHT wrote: Show quoted text
> 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;
$ git commit -m "pid_running returns 0 on a PID less than 1 as reported by James Wright" Created commit 2479dcc: pid_running returns 0 on a PID less than 1 as reported by James Wright 1 files changed, 1 insertions(+), 1 deletions(-)