From 012f6a2be96dd337abc101c98e3bce137af1679c Mon Sep 17 00:00:00 2001 From: Slaven Rezic Date: Wed, 29 Oct 2014 15:59:24 +0100 Subject: [PATCH] pid check works now for all users Running "status" used to show the wrong result if the daemon was started for a different user. According to perlipc.pod it's best to check for $!{EPERM} after a failed kill 0 => ... The pid_running() function was also simplified to call kill 0 => ... only once, the 2nd call was actually redundant. --- lib/Daemon/Control.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Daemon/Control.pm b/lib/Daemon/Control.pm index 2d3dbb3..ab95a51 100644 --- a/lib/Daemon/Control.pm +++ b/lib/Daemon/Control.pm @@ -358,7 +358,7 @@ sub pid_running { $pid ||= $self->read_pid; return 0 unless $self->pid >= 1; - return 0 unless kill 0, $self->pid; + return 0 unless (kill(0, $self->pid) || $!{EPERM}); if ( $self->scan_name ) { open my $lf, "-|", "ps", "-p", $self->pid, "-o", "command=" @@ -367,9 +367,9 @@ sub pid_running { return 1 if $line =~ $self->scan_name; } return 0; + } else { + return 1; } - # Scan name wasn't used, testing normal PID. - return kill 0, $self->pid; } sub process_running { -- 1.8.3.4