86 lines
3.5 KiB
Diff
86 lines
3.5 KiB
Diff
|
|
From fe24a6a55e8850298b496c5b9d82f1866eba190e Mon Sep 17 00:00:00 2001
|
||
|
|
From: Chet Ramey <chet.ramey@case.edu>
|
||
|
|
Date: Mon, 30 Oct 2023 12:16:07 -0400
|
||
|
|
Subject: [PATCH] changes to SIGINT handler while waiting for a child; skip
|
||
|
|
vertical whitespace after translating an integer
|
||
|
|
|
||
|
|
Conflict:partial round, only the modified content of jobs.c is rounded.
|
||
|
|
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=fe24a6a55e8850298b496c5b9d82f1866eba190e
|
||
|
|
---
|
||
|
|
jobs.c | 24 ++++++++++++++++--------
|
||
|
|
1 file changed, 16 insertions(+), 8 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/jobs.c b/jobs.c
|
||
|
|
index b8373cf5..59c46475 100644
|
||
|
|
--- a/jobs.c
|
||
|
|
+++ b/jobs.c
|
||
|
|
@@ -2664,6 +2664,10 @@ wait_for_background_pids (struct procstat *ps)
|
||
|
|
#define INVALID_SIGNAL_HANDLER (SigHandler *)wait_for_background_pids
|
||
|
|
static SigHandler *old_sigint_handler = INVALID_SIGNAL_HANDLER;
|
||
|
|
|
||
|
|
+/* The current SIGINT handler as set by restore_sigint_handler. Only valid
|
||
|
|
+ immediately after restore_sigint_handler, used for continuations. */
|
||
|
|
+static SigHandler *cur_sigint_handler = INVALID_SIGNAL_HANDLER;
|
||
|
|
+
|
||
|
|
static int wait_sigint_received;
|
||
|
|
static int child_caught_sigint;
|
||
|
|
|
||
|
|
@@ -2681,6 +2685,7 @@ wait_sigint_cleanup (void)
|
||
|
|
static void
|
||
|
|
restore_sigint_handler ()
|
||
|
|
{
|
||
|
|
+ cur_sigint_handler = old_sigint_handler;
|
||
|
|
if (old_sigint_handler != INVALID_SIGNAL_HANDLER)
|
||
|
|
{
|
||
|
|
set_signal_handler (SIGINT, old_sigint_handler);
|
||
|
|
@@ -2703,8 +2708,7 @@ wait_sigint_handler (int sig)
|
||
|
|
restore_sigint_handler ();
|
||
|
|
/* If we got a SIGINT while in `wait', and SIGINT is trapped, do
|
||
|
|
what POSIX.2 says (see builtins/wait.def for more info). */
|
||
|
|
- if (this_shell_builtin && this_shell_builtin == wait_builtin &&
|
||
|
|
- signal_is_trapped (SIGINT) &&
|
||
|
|
+ if (signal_is_trapped (SIGINT) &&
|
||
|
|
((sigint_handler = trap_to_sighandler (SIGINT)) == trap_handler))
|
||
|
|
{
|
||
|
|
trap_handler (SIGINT); /* set pending_traps[SIGINT] */
|
||
|
|
@@ -2727,6 +2731,8 @@ wait_sigint_handler (int sig)
|
||
|
|
{
|
||
|
|
set_exit_status (128+SIGINT);
|
||
|
|
restore_sigint_handler ();
|
||
|
|
+ if (cur_sigint_handler == INVALID_SIGNAL_HANDLER)
|
||
|
|
+ set_sigint_handler (); /* XXX - only do this in one place */
|
||
|
|
kill (getpid (), SIGINT);
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -2876,11 +2882,13 @@ wait_for (pid_t pid, int flags)
|
||
|
|
{
|
||
|
|
SigHandler *temp_sigint_handler;
|
||
|
|
|
||
|
|
- temp_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
|
||
|
|
- if (temp_sigint_handler == wait_sigint_handler)
|
||
|
|
- internal_debug ("wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = %d", running_trap);
|
||
|
|
- else
|
||
|
|
- old_sigint_handler = temp_sigint_handler;
|
||
|
|
+ temp_sigint_handler = old_sigint_handler;
|
||
|
|
+ old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
|
||
|
|
+ if (old_sigint_handler == wait_sigint_handler)
|
||
|
|
+ {
|
||
|
|
+ internal_debug ("wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = %d", running_trap);
|
||
|
|
+ old_sigint_handler = temp_sigint_handler;
|
||
|
|
+ }
|
||
|
|
waiting_for_child = 0;
|
||
|
|
if (old_sigint_handler == SIG_IGN)
|
||
|
|
set_signal_handler (SIGINT, old_sigint_handler);
|
||
|
|
@@ -4105,7 +4113,7 @@ set_job_status_and_cleanup (int job)
|
||
|
|
SIGINT (if we reset the sighandler to the default).
|
||
|
|
In this case, we have to fix things up. What a crock. */
|
||
|
|
if (temp_handler == trap_handler && signal_is_trapped (SIGINT) == 0)
|
||
|
|
- temp_handler = trap_to_sighandler (SIGINT);
|
||
|
|
+ temp_handler = trap_to_sighandler (SIGINT);
|
||
|
|
restore_sigint_handler ();
|
||
|
|
if (temp_handler == SIG_DFL)
|
||
|
|
termsig_handler (SIGINT); /* XXX */
|
||
|
|
--
|
||
|
|
2.33.0
|
||
|
|
|