Whoops, looks like O_TRUNC was missing when opening the file,

increasing the chance of left-overs from older pid contents in the
file.
This commit is contained in:
Joey Schulze 2003-09-28 02:38:18 +00:00
parent 0f9873bed4
commit 071356e5d6

View File

@ -87,7 +87,7 @@ int write_pid (char *pidfile)
int fd;
int pid;
if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1)
if ( ((fd = open(pidfile, O_RDWR|O_CREAT|O_TRUNC, 0644)) == -1)
|| ((f = fdopen(fd, "r+")) == NULL) ) {
fprintf(stderr, "Can't open or create %s.\n", pidfile);
return 0;