in reply to Re: Keeping File Locks after Daemonization
in thread Keeping File Locks after Daemonization
have you tested that well? i just days ago did the same and found...
# Proc/PID/File.pm sub alive { my $self = shift; my $pid = $self->read(); print "> Proc::PID::File - pid: $pid" if $self->{debug}; return $pid if $pid && $pid != $$ && kill(0, $pid); # $self->write(); return 0; } # i've commented out the write() because i don't think that testing # for aliveness should write a pidfile... sub DESTROY { my $self = shift; $self->remove() if $self->{path} and $self->{written}; } # i've added a written test so i don't remove pidfiles that aren't min +e # add this to the end of write() $self->{written} = 1; # add this to file() $self->{written} = 0;
because:
would delete the pidfile that it found...die "Already running!" if Proc::PID::File->new()->alive();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Keeping File Locks after Daemonization
by cees (Curate) on Jan 31, 2003 at 05:11 UTC |