Truncate PID file after opening and locking

This commit is contained in:
C. McEnroe 2020-08-17 15:59:45 -04:00
parent 00e35a1031
commit 620735523f

View File

@ -251,6 +251,9 @@ int main(int argc, char *argv[]) {
pidPath, O_WRONLY | O_CREAT | O_EXLOCK | O_CLOEXEC, 0600 pidPath, O_WRONLY | O_CREAT | O_EXLOCK | O_CLOEXEC, 0600
); );
if (pidFile < 0) err(EX_CANTCREAT, "%s", pidPath); if (pidFile < 0) err(EX_CANTCREAT, "%s", pidPath);
error = ftruncate(pidFile, 0);
if (error) err(EX_IOERR, "%s", pidPath);
} }
// We can't lock a named pipe, so just warn if it already exists. // We can't lock a named pipe, so just warn if it already exists.