From 893cc4558558db41e16525303023372496a293b7 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 3 Nov 2012 23:44:59 +0800 Subject: [PATCH] Fix a race condition in wait_reading_process_output (tiny change). * src/process.c (wait_reading_process_output): Avoid a race condition with SIGIO delivery. Fixes: debbugs:11536 --- src/ChangeLog | 5 +++++ src/process.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1595537267d..e26dd561495 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-11-03 Jim Paris (tiny change) + + * process.c (wait_reading_process_output): Avoid a race condition + with SIGIO delivery (Bug#11536). + 2012-11-03 Chong Yidong * buffer.c (cursor_type): Untabify docstring. diff --git a/src/process.c b/src/process.c index 77e99ead01f..dae687cb59c 100644 --- a/src/process.c +++ b/src/process.c @@ -4697,9 +4697,12 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, /* If we woke up due to SIGWINCH, actually change size now. */ do_pending_window_change (0); + /* The following optimization fails if SIGIO is received between + set_waiting_for_input and select (Bug#11536). if ((time_limit || nsecs) && nfds == 0 && ! timeout_reduced_for_timers) - /* We waited the full specified time, so return now. */ break; + */ + if (nfds < 0) { if (xerrno == EINTR) -- 2.39.5