From 20154f7094e713ddfd878f6141ee0ea9375019f1 Mon Sep 17 00:00:00 2001 From: Devin Carraway Date: Sun, 10 Jul 2005 11:46:15 +0000 Subject: [PATCH] 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 --- qpsmtpd-forkserver | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qpsmtpd-forkserver b/qpsmtpd-forkserver index c89b8ef..9bb89be 100755 --- a/qpsmtpd-forkserver +++ b/qpsmtpd-forkserver @@ -116,6 +116,8 @@ if ($PID_FILE) { } seek PID, 0, 0 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 { open PID, ">$PID_FILE" or die "open pid_file: $!\n";