Skip Menu |

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

Report information
The Basics
Id: 23935
Status: new
Priority: 0/
Queue: Proc-PID-File

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

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



Subject: failure to check return value of sysseek/truncate/syswrite may lead to false positive
When writing the PID to the pidfile, Proc::PID::File does not check the return value of the file functions sysseek, truncate and syswrite. Under certain conditions, these calls may fail, after which running() will erroneously return false. As a result, multiple instances of your program may be active at the same time. I have attached a suggested patch, considering that "die" is favorable over mistakenly returning false. FWIW, I encountered a problem when my /var partition ran out of disk space. Proc::PID::File then created an empty pid file, leading subsequent instances to the conclusion that my daemon wasn't running. Environment: Proc::Pid::File version 1.24 perl 5.8.8 built for i686-linux CentOS 4.x on i686, kernel 2.6.9-34.0.1.ELsmp
Subject: proc-pid-file.diff
--- orig/Proc/PID/File.pm 2004-04-08 02:27:25.000000000 +0000 +++ fixed/Proc/PID/File.pm 2006-12-14 15:36:02.000000000 +0000 @@ -109,9 +109,9 @@ } $self->debug("writing: $$"); - sysseek FH, 0, 0; - truncate FH, 0; - syswrite FH, "$$\n", length("$$\n"); + sysseek FH, 0, 0 or die "sysseek failed: $!"; + truncate FH, 0 or die "truncate failed: $!"; + syswrite FH, "$$\n", length("$$\n") or die "syswrite failed: $!"; close(FH) || die qq/Cannot write pid file "$path": $!\n/; return 0;