From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] passt: Truncate PID file on open() Date: Fri, 22 Jul 2022 19:42:32 +0200 Message-ID: <20220722174232.438316-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7797181424551897127==" --===============7797181424551897127== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Otherwise, if the current PID has fewer digits than a previously written one, the content will be wrong. Signed-off-by: Stefano Brivio --- passt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passt.c b/passt.c index a8d94b4..01eed1b 100644 --- a/passt.c +++ b/passt.c @@ -390,7 +390,7 @@ int main(int argc, char **argv) if (*c.pid_file) { if ((pidfile_fd = open(c.pid_file, - O_CREAT | O_WRONLY | O_CLOEXEC, + O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, S_IRUSR | S_IWUSR)) < 0) { perror("PID file open"); exit(EXIT_FAILURE); -- 2.35.1 --===============7797181424551897127==--