Skip Menu |

This queue is for tickets about the Proc-Pidfile CPAN distribution.

Report information
The Basics
Id: 56630
Status: resolved
Priority: 0/
Queue: Proc-Pidfile

People
Owner: NEILB [...] cpan.org
Requestors: depesz [...] depesz.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 1.02



Subject: Removal dependency on Proc::ProcessTable
sub _is_running is getting list of all processes in system just to check if given process exists. There is better way of handling it, and it also reduces dependencies: we can use kill(0, $pid) to check for process existence. It will work on everything except RISC OS, but I don't think that this system is currently very important. Anyway - please find attached patch that removes the dependency and checks for pid with kill(0, $pid).
Subject: proc-pidfile.patch
--- Pidfile.pm.orig 2010-04-15 13:42:40.000000000 +0200 +++ Pidfile.pm 2010-04-15 13:44:11.000000000 +0200 @@ -3,7 +3,6 @@ $VERSION = '1.005'; use Fcntl qw( :flock ); use File::Basename qw( basename ); -require Proc::ProcessTable; require File::Spec; sub new @@ -61,9 +60,8 @@ sub _is_running { my $pid = shift; - my $table = Proc::ProcessTable->new()->table; - my %processes = map { $_->pid => $_ } @$table; - return exists $processes{$pid}; + die "This isn't going to work on RISC OS, if you really want a pid file on this system please send me a patch.\n" if 'riscos' eq $^O; + return kill(0, $pid); } sub _create_pidfile
On 2010-04-15 07:46:59, DEPESZ wrote: Show quoted text
> sub _is_running is getting list of all processes in system just to check > if given process exists. There is better way of handling it, and it also > reduces dependencies: we can use kill(0, $pid) to check for process > existence. > > It will work on everything except RISC OS, but I don't think that this > system is currently very important. > > Anyway - please find attached patch that removes the dependency and > checks for pid with kill(0, $pid).
According to "perldoc perlipc" one should also check for EPERM here: kill 0 => $pid or $!{EPERM} Also, just for riscos the old Proc::ProcessTable code could be preserved. Something like this: if ($^O eq 'riscos') { require Proc::ProcessTable; ... code using Proc::ProcessTable ... } else { kill 0 => $pid or $!{EPERM} } Regards, Slaven
Thanks -- fixed in 1.02 Neil