Blob Blame History Raw
---
 array.c                  |    2 +-
 examples/loadables/tee.c |    3 ++-
 hashlib.c                |    4 ++--
 jobs.c                   |    9 +++++++++
 sig.c                    |    4 ++--
 sig.h                    |    4 ++--
 trap.c                   |    2 +-
 trap.h                   |    2 +-
 8 files changed, 20 insertions(+), 10 deletions(-)

--- array.c
+++ array.c	2020-10-12 16:00:37.207185803 +0000
@@ -1028,7 +1028,7 @@ char	*s, *sep;
  * To make a running version, compile -DTEST_ARRAY and link with:
  * 	xmalloc.o syntax.o lib/malloc/libmalloc.a lib/sh/libsh.a
  */
-int interrupt_immediately = 0;
+volatile sig_atomic_t interrupt_immediately = 0;
 
 int
 signal_is_trapped(s)
--- examples/loadables/tee.c
+++ examples/loadables/tee.c	2020-10-12 16:00:37.267184666 +0000
@@ -35,6 +35,7 @@
 #include "bashansi.h"
 
 #include <stdio.h>
+#include <signal.h>
 #include <errno.h>
 
 #include "builtins.h"
@@ -56,7 +57,7 @@ static FLIST *tee_flist;
 
 #define TEE_BUFSIZE	8192
 
-extern int interrupt_immediately;
+extern volatile sig_atomic_t interrupt_immediately;
 
 extern char *strerror ();
 
--- hashlib.c
+++ hashlib.c	2020-10-12 16:02:31.677016331 +0000
@@ -473,8 +473,8 @@ hash_pstats (table, name)
 
 HASH_TABLE *table, *ntable;
 
-int interrupt_immediately = 0;
-int running_trap = 0;
+volatile sig_atomic_t interrupt_immediately = 0;
+volatile sig_atomic_t running_trap = 0;
 
 int
 signal_is_trapped (s)
--- jobs.c
+++ jobs.c	2020-10-12 16:00:37.267184666 +0000
@@ -2223,6 +2223,15 @@ make_child (command, flags)
 	 child process, go back and change callers who free `command' in
 	 the child process when this returns. */
       mypid = getpid ();
+
+      if (interrupt_state)
+	{
+	  struct timeval tv;
+	  struct rusage   rx;
+	  (void) gettimeofday(&tv, NULL);
+	  (void) getrusage(RUSAGE_SELF, &rx);
+	}
+
 #if defined (BUFFERED_INPUT)
       /* Close default_buffered_input if it's > 0.  We don't close it if it's
 	 0 because that's the file descriptor used when redirecting input,
--- sig.c
+++ sig.c	2020-10-12 16:00:37.267184666 +0000
@@ -84,10 +84,10 @@ sigset_t top_level_mask;
 #endif /* JOB_CONTROL */
 
 /* When non-zero, we throw_to_top_level (). */
-int interrupt_immediately = 0;
+volatile sig_atomic_t interrupt_immediately = 0;
 
 /* When non-zero, we call the terminating signal handler immediately. */
-int terminate_immediately = 0;
+volatile sig_atomic_t terminate_immediately = 0;
 
 #if defined (SIGWINCH)
 static SigHandler *old_winch = (SigHandler *)SIG_DFL;
--- sig.h
+++ sig.h	2020-10-12 16:03:44.403637781 +0000
@@ -109,8 +109,8 @@ do { \
 extern volatile sig_atomic_t sigwinch_received;
 extern volatile sig_atomic_t sigterm_received;
 
-extern int interrupt_immediately;	/* no longer used */
-extern int terminate_immediately;
+extern volatile sig_atomic_t interrupt_immediately;	/* no longer used */
+extern volatile sig_atomic_t terminate_immediately;
 
 /* Functions from sig.c. */
 extern sighandler termsig_sighandler PARAMS((int));
--- trap.c
+++ trap.c	2020-10-12 16:08:10.102600477 +0000
@@ -111,7 +111,7 @@ int pending_traps[NSIG];
    Used in execute_cmd.c and builtins/common.c to clean up when
    parse_and_execute does not return normally after executing the
    trap command (e.g., when `return' is executed in the trap command). */
-int running_trap;
+volatile sig_atomic_t running_trap;
 
 /* Set to last_command_exit_value before running a trap. */
 int trap_saved_exit_value;
--- trap.h
+++ trap.h	2020-10-12 16:05:57.105122164 +0000
@@ -62,7 +62,7 @@ extern char *trap_list[];
 
 extern int trapped_signal_received;
 extern int wait_signal_received;
-extern int running_trap;
+extern volatile sig_atomic_t running_trap;
 extern int trap_saved_exit_value;
 extern int suppress_debug_trap_verbose;