diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-31 19:26:03 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-31 19:26:03 +0100 |
commit | 0fd74dcac3257fda689e20e457bb6963d14a3a5b (patch) | |
tree | 9ace3515126cab836478a73c6e5b6d4cc9bb2356 /src | |
parent | fix some errors (diff) | |
download | sat-0fd74dcac3257fda689e20e457bb6963d14a3a5b.tar.gz sat-0fd74dcac3257fda689e20e457bb6963d14a3a5b.tar.bz2 sat-0fd74dcac3257fda689e20e457bb6963d14a3a5b.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r-- | src/client.c | 5 | ||||
-rw-r--r-- | src/daemon.h | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/client.c b/src/client.c index 415ed79..b37b9e3 100644 --- a/src/client.c +++ b/src/client.c @@ -59,7 +59,7 @@ send_command(enum command cmd, size_t n, const char *restrict msg) ssize_t r, wrote; char *buf = NULL; signed char cmd_ = (signed char)cmd; - int saved_errno; + int eot = 0, saved_errno; /* Get socket address. */ dir = getenv("XDG_RUNTIME_DIR"), dir = (dir ? dir : "/run"); @@ -118,6 +118,7 @@ receive_again: outfd = (int)cmd_; goterr |= outfd == STDERR_FILENO; t (r = read(fd, &n, sizeof(n)), r < (ssize_t)sizeof(n)); + eot = (outfd == 127) & !n; t (!(buf = malloc(n))); while (n) { t (r = read(fd, buf, n), r < 0); @@ -143,6 +144,8 @@ fail: close(fd); free(buf); errno = saved_errno; + if (eot) + goto done; return -1; } diff --git a/src/daemon.h b/src/daemon.h index 980cd64..5aaa1c6 100644 --- a/src/daemon.h +++ b/src/daemon.h @@ -113,6 +113,7 @@ static const char *failed__ = NULL; */ #define DAEMON_CLEANUP_START \ done: \ + (void) send_string(SOCK_FILENO, 127, NULL); \ shutdown(SOCK_FILENO, SHUT_WR); \ close(SOCK_FILENO); \ close(STATE_FILENO) |