From: Jérémie Galarneau Date: Fri, 18 Sep 2015 19:50:02 +0000 (-0400) Subject: Fix: Handle hang-up gracefully in run-as X-Git-Tag: v2.8.0-rc1~317 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=da9ee8323287d74fc2ec5477ecf83e61da36f5ce;p=lttng-tools.git Fix: Handle hang-up gracefully in run-as Signed-off-by: Jérémie Galarneau --- 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: