From 07ea10a0b51eea66af82acfd4d3654d62fa52c83 Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Wed, 11 Oct 2023 21:36:17 -0700 Subject: [PATCH] Update pidfile processing to truncate when writing pid --- tool/net/redbean.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/net/redbean.c b/tool/net/redbean.c index dc70c27f9..a1221b460 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -7407,7 +7407,7 @@ void RedBean(int argc, char *argv[]) { Daemonize(); } if (pidpath) { - fd = open(pidpath, O_CREAT | O_WRONLY, 0644); + fd = open(pidpath, O_CREAT | O_WRONLY | O_TRUNC, 0644); WRITE(fd, ibuf, FormatInt32(ibuf, getpid()) - ibuf); close(fd); }