Skip Menu |

This queue is for tickets about the File-Pid-Quick CPAN distribution.

Report information
The Basics
Id: 59433
Status: new
Priority: 0/
Queue: File-Pid-Quick

People
Owner: Nobody in particular
Requestors: JACOB [...] cpan.org
Cc:
AdminCc:

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



Subject: Not safe for daemonizing programs
in check(): If the PID file exists and it was created by the current program it is not re- created even if it contains a different PID than the current program's. Testcase: check(); fork()/daemonize(); (re)check() -- now the PID file exists but contains an invalid PID while the program keeps running. Testcase 2: check; sleep(); (on other console: echo "9999" > pid.PID), check(); --- the check succeeds but the program is NOT pid-file-protected and could be started a second time. Workaround: clear @File::Pid::Quick::pid_files_created before calling check(). Fix: in check(): my $recreate = undef; if($pid != $$ and kill 0, $pid) { [...] } } elsif ($pid != $$) { $recreate = 1; } close $pid_in; } if($recreate or not grep { $_ eq $pid_file } @pid_files_created) { ===== PS: "my $pid_data = <$pid_in>;" should be expanded to "my $pid_data = <$pid_in>; $pid_data = '' if not defined $PID_data;" to avoid warnings if the file has 0-length.
BTW: the elsif is for the if I copied in, even if its not really visible because I shortened the code badly.