If the PID file already exists at startup, truncate to zero-length before

attempting to re-use it.  Otherwise if the new PID is shorter than the
previous one the file will be corrupted by the rewrite (harmlessly the way it
is being read by this code, but problematically for anything that expects to
be able to run something similar to /bin/kill `cat /path/to/pid.file`)


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@493 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Devin Carraway 2005-07-10 11:46:15 +00:00
parent 58cce1ab30
commit 20154f7094

View File

@ -116,6 +116,8 @@ if ($PID_FILE) {
} }
seek PID, 0, 0 seek PID, 0, 0
or die "Could not seek back to beginning of $PID_FILE: $!\n"; or die "Could not seek back to beginning of $PID_FILE: $!\n";
truncate PID, 0
or die "Could not truncate $PID_FILE at 0: $!";
} else { } else {
open PID, ">$PID_FILE" open PID, ">$PID_FILE"
or die "open pid_file: $!\n"; or die "open pid_file: $!\n";