From 23fc3599e82e137da2276764b9d4d7c7cced8747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 16 Mar 2015 21:37:59 +0100 Subject: [PATCH] qrexec: better handle remote process termination If remote end terminates without proper protocol finish (MSG_DATA_EXIT_CODE), terminate also local part instead of waiting indefinitely. --- qrexec/qrexec-agent-data.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qrexec/qrexec-agent-data.c b/qrexec/qrexec-agent-data.c index fb4d9c6..ae5057e 100644 --- a/qrexec/qrexec-agent-data.c +++ b/qrexec/qrexec-agent-data.c @@ -296,12 +296,21 @@ int process_child_io(libvchan_t *data_vchan, /* if all done, exit the loop */ if ((!child_process_pid || child_process_status > -1) && + (child_process_pid || remote_process_status > -1) && stdin_fd == -1 && stdout_fd == -1 && stderr_fd == -1) { if (child_process_status > -1) { send_exit_code(data_vchan, child_process_status); } break; } + /* also if vchan is disconnected (and we processed all the data), there + * is no sense of processing further data */ + if (!libvchan_data_ready(data_vchan) && !libvchan_is_open(data_vchan)) { + if (child_process_pid) + return remote_process_status; + else + return child_process_status; + } /* child signaled desire to use single socket for both stdin and stdout */ if (stdio_socket_requested) { if (stdout_fd != -1)