Update pidfile processing to truncate when writing pid (#910)

This commit is contained in:
Paul Kulchenko 2023-10-11 21:45:27 -07:00 committed by GitHub
parent 6e4b9b6515
commit f92ad74e6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}