From ec60102755fcc8c157cd43b0ec5d106f1d26a97a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 18 Sep 2015 15:50:02 -0400 Subject: [PATCH] Fix: Handle hang-up gracefully in run-as MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/common/runas.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/runas.c b/src/common/runas.c index daba9937c..42ca55266 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -216,7 +216,9 @@ int do_recv_fd(struct run_as_worker *worker, return 0; } len = lttcomm_recv_fds_unix_sock(worker->sockpair[0], fd, 1); - if (len < 0) { + if (!len) { + return -1; + } else if (len < 0) { PERROR("lttcomm_recv_fds_unix_sock"); return -1; } @@ -392,14 +394,19 @@ int run_as_cmd(struct run_as_worker *worker, /* receive return value */ readlen = lttcomm_recv_unix_sock(worker->sockpair[0], &recvret, sizeof(recvret)); - if (readlen < sizeof(recvret)) { + if (!readlen) { + ERR("Run-as worker has hung-up during run_as_cmd"); + recvret.ret = -1; + recvret._errno = EIO; + goto end; + } else if (readlen < sizeof(recvret)) { PERROR("Error reading response from run_as"); recvret.ret = -1; recvret._errno = errno; } if (do_recv_fd(worker, cmd, &recvret.ret)) { recvret.ret = -1; - recvret._errno = -EIO; + recvret._errno = EIO; } end: -- 2.34.1