From 0fd74dcac3257fda689e20e457bb6963d14a3a5b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 31 Dec 2015 19:26:03 +0100 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- TODO | 1 - doc/info/chap/output.texinfo | 7 ++++++- src/client.c | 5 ++++- src/daemon.h | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 37dc44f..bef866e 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,2 @@ We probably shall save the working directory too. -The daemon shall always send an ACK when it is done. diff --git a/doc/info/chap/output.texinfo b/doc/info/chap/output.texinfo index 4b3d98c..d475706 100644 --- a/doc/info/chap/output.texinfo +++ b/doc/info/chap/output.texinfo @@ -61,6 +61,11 @@ is all arguments in the job's command line, including @item ENVP is all environment variables. Each entry is quoted if necessary so it can be pasted to the shell and used -with @command{env}. +with @command{env}. Because this use usally a lot of +data, which you usually are not interrested in, it +can be a good idea to pipe the output of @command{satq} +to @command{grep -v '^ envp:'}. If you do this, +you should be aware that @command{grep} will fail +if there is no output. @end table 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) -- cgit v1.2.3-70-g09d2