diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-12-03 23:19:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-12-03 23:19:55 +0000 |
commit | 05550b1ac2fb18090586d104c50b90819a5da015 (patch) | |
tree | c910ad29c47aee34269d1ad387d5fa3bdbaed9d7 /pidfile.c | |
parent | 441ffb68a7d89556da0efe8fdf64538acc5eeb87 (diff) | |
download | cmogstored-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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) |