From 4f17e0b6d2a7a5aacb0aaa4f56f4ae48e7c3e369 Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Sat, 26 Jul 2008 17:30:35 +0000 Subject: [PATCH] Clean up printing to PID file and logging of that --- src/daemonitor/300_pid.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/daemonitor/300_pid.c b/src/daemonitor/300_pid.c index 65e0b29..3982367 100644 --- a/src/daemonitor/300_pid.c +++ b/src/daemonitor/300_pid.c @@ -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; }