Avoid aborts when a thread is signaled while "waiting for input".
* src/process.c (kbd_is_ours): New function. (wait_reading_process_output): Set 'waiting_for_input' only if the current thread is monitoring the keyboard descriptor. See also https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg01180.html. (Bug#51229)
This commit is contained in:
parent
21397cce51
commit
e8488808df
1 changed files with 19 additions and 3 deletions
|
@ -683,6 +683,22 @@ clear_waiting_thread_info (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return TRUE if the keyboard descriptor is being monitored by the
|
||||||
|
current thread, FALSE otherwise. */
|
||||||
|
static bool
|
||||||
|
kbd_is_ours (void)
|
||||||
|
{
|
||||||
|
for (int fd = 0; fd <= max_desc; ++fd)
|
||||||
|
{
|
||||||
|
if (fd_callback_info[fd].waiting_thread != current_thread)
|
||||||
|
continue;
|
||||||
|
if ((fd_callback_info[fd].flags & (FOR_READ | KEYBOARD_FD))
|
||||||
|
== (FOR_READ | KEYBOARD_FD))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Compute the Lisp form of the process status, p->status, from
|
/* Compute the Lisp form of the process status, p->status, from
|
||||||
the numeric status that was returned by `wait'. */
|
the numeric status that was returned by `wait'. */
|
||||||
|
@ -5312,13 +5328,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
|
||||||
wait_reading_process_output_1 ();
|
wait_reading_process_output_1 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cause C-g and alarm signals to take immediate action,
|
/* Cause C-g signals to take immediate action,
|
||||||
and cause input available signals to zero out timeout.
|
and cause input available signals to zero out timeout.
|
||||||
|
|
||||||
It is important that we do this before checking for process
|
It is important that we do this before checking for process
|
||||||
activity. If we get a SIGCHLD after the explicit checks for
|
activity. If we get a SIGCHLD after the explicit checks for
|
||||||
process activity, timeout is the only way we will know. */
|
process activity, timeout is the only way we will know. */
|
||||||
if (read_kbd < 0)
|
if (read_kbd < 0 && kbd_is_ours ())
|
||||||
set_waiting_for_input (&timeout);
|
set_waiting_for_input (&timeout);
|
||||||
|
|
||||||
/* If status of something has changed, and no input is
|
/* If status of something has changed, and no input is
|
||||||
|
@ -5448,7 +5464,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
|
||||||
{
|
{
|
||||||
clear_waiting_for_input ();
|
clear_waiting_for_input ();
|
||||||
redisplay_preserve_echo_area (11);
|
redisplay_preserve_echo_area (11);
|
||||||
if (read_kbd < 0)
|
if (read_kbd < 0 && kbd_is_ours ())
|
||||||
set_waiting_for_input (&timeout);
|
set_waiting_for_input (&timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue