From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH] passt: Truncate PID file on open() Date: Sat, 23 Jul 2022 12:27:25 +1000 Message-ID: In-Reply-To: <20220722174232.438316-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2992001116007272131==" --===============2992001116007272131== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Fri, Jul 22, 2022 at 07:42:32PM +0200, Stefano Brivio wrote: > Otherwise, if the current PID has fewer digits than a previously > written one, the content will be wrong. > > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > 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); -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --===============2992001116007272131== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1MYlhIb0FDZ2tRZ3lwWTRnRXcKWVNMY0RBLy9TbFZPdjVPeHkx UHNPRWRISUFuYTh0MTRwNGIwdjkxbjlkNktyVlRwVXVpSFp2RXJzRzZEcDJzZApBSUFDc01zWnhZ Y1R5cHk5QUVWYVlvQjArYzIyeFo2ajQxZVE0NVNBW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