Clean up printing to PID file and logging of that

This commit is contained in:
Laurence Withers 2008-07-26 17:30:35 +00:00
parent 67f0ab405a
commit 4f17e0b6d2
1 changed files with 2 additions and 5 deletions

View File

@ -166,10 +166,7 @@ int pidfile_write(void)
return -1; /* come back later */
}
snprintf(buf, sizeof(buf), "%lu\n", (unsigned long)getpid());
ret = safe_write_fixed(fd, buf, strlen(buf));
if((size_t)ret != strlen(buf)) {
if(dprintf(fd, "%lu\n", (unsigned long)getpid()) == -1) {
LOG(LOG_ERR, "Couldn't write to PID file `%s' (%m).", pidfile_filename);
TEMP_FAILURE_RETRY( close(fd) );
return -1; /* come back later */
@ -181,7 +178,7 @@ int pidfile_write(void)
}
/* success -- log, register handler, return */
LOG(LOG_NOTICE, "PID %s written to `%s'.", buf, pidfile_filename);
LOG(LOG_NOTICE, "Wrote PID %lu to `%s'.", (unsigned long)getpid(), pidfile_filename);
atexit(pidfile_unlink);
return 0;
}