qrexec: periodically check if remote domain/process still exists

This commit is contained in:
Marek Marczykowski-Górecki 2015-02-22 18:25:14 +01:00
parent 9ea5790a9b
commit e76007fe20

View File

@ -410,6 +410,7 @@ static void select_loop(libvchan_t *vchan)
int vchan_fd; int vchan_fd;
sigset_t selectmask; sigset_t selectmask;
struct timespec zero_timeout = { 0, 0 }; struct timespec zero_timeout = { 0, 0 };
struct timespec select_timeout = { 10, 0 };
sigemptyset(&selectmask); sigemptyset(&selectmask);
sigaddset(&selectmask, SIGCHLD); sigaddset(&selectmask, SIGCHLD);
@ -434,7 +435,7 @@ static void select_loop(libvchan_t *vchan)
&zero_timeout, &selectmask); &zero_timeout, &selectmask);
} else } else
ret = pselect(max_fd + 1, &select_set, NULL, NULL, ret = pselect(max_fd + 1, &select_set, NULL, NULL,
NULL, &selectmask); &select_timeout, &selectmask);
if (ret < 0) { if (ret < 0) {
if (errno == EINTR && local_pid > 0) { if (errno == EINTR && local_pid > 0) {
continue; continue;
@ -443,6 +444,12 @@ static void select_loop(libvchan_t *vchan)
do_exit(1); 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)) if (FD_ISSET(vchan_fd, &select_set))
libvchan_wait(vchan); libvchan_wait(vchan);
while (libvchan_data_ready(vchan)) while (libvchan_data_ready(vchan))