From e76007fe20d324e4c93d0e9d9e30563c2dd6c95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 22 Feb 2015 18:25:14 +0100 Subject: [PATCH] qrexec: periodically check if remote domain/process still exists --- qrexec/qrexec-client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qrexec/qrexec-client.c b/qrexec/qrexec-client.c index 45b27c5..24e1ba4 100644 --- a/qrexec/qrexec-client.c +++ b/qrexec/qrexec-client.c @@ -410,6 +410,7 @@ static void select_loop(libvchan_t *vchan) int vchan_fd; sigset_t selectmask; struct timespec zero_timeout = { 0, 0 }; + struct timespec select_timeout = { 10, 0 }; sigemptyset(&selectmask); sigaddset(&selectmask, SIGCHLD); @@ -434,7 +435,7 @@ static void select_loop(libvchan_t *vchan) &zero_timeout, &selectmask); } else ret = pselect(max_fd + 1, &select_set, NULL, NULL, - NULL, &selectmask); + &select_timeout, &selectmask); if (ret < 0) { if (errno == EINTR && local_pid > 0) { continue; @@ -443,6 +444,12 @@ static void select_loop(libvchan_t *vchan) do_exit(1); } } + if (ret == 0) { + if (!libvchan_is_open(vchan)) { + /* remote disconnected witout a proper signaling */ + do_exit(1); + } + } if (FD_ISSET(vchan_fd, &select_set)) libvchan_wait(vchan); while (libvchan_data_ready(vchan))