about summary refs log tree commit homepage
path: root/pidfile.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-12-03 23:19:55 +0000
committerEric Wong <normalperson@yhbt.net>2012-12-03 23:19:55 +0000
commit05550b1ac2fb18090586d104c50b90819a5da015 (patch)
treec910ad29c47aee34269d1ad387d5fa3bdbaed9d7 /pidfile.c
parent441ffb68a7d89556da0efe8fdf64538acc5eeb87 (diff)
downloadcmogstored-05550b1ac2fb18090586d104c50b90819a5da015.tar.gz
dprintf() may return a non-negative value and still set ENOSPC
on partially-written data.
Diffstat (limited to 'pidfile.c')
-rw-r--r--pidfile.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pidfile.c b/pidfile.c
index a0a9fae..f19ae88 100644
--- a/pidfile.c
+++ b/pidfile.c
@@ -76,8 +76,11 @@ int mog_pidfile_commit(int fd)
         assert(lseek(fd, 0, SEEK_CUR) == 0 && "pidfile offset != 0");
         assert(pidfile && "mog_pidfile_open not called (or unsuccessful)");
 
-        if (dprintf(fd, "%d\n", (int)getpid()) <= 1) {
+        errno = 0;
+        if (dprintf(fd, "%d\n", (int)getpid()) <= 1 || errno == ENOSPC) {
                 PRESERVE_ERRNO( close(fd) );
+                if (errno == ENOSPC)
+                        PRESERVE_ERRNO( pidfile_atexit() );
                 return -1;
         }
         if (close(fd) < 0 && errno != EINTR)