]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* function.c (shell_completed): [SV 51014] Add signal to .SHELLSTATUS
authorPaul Smith <psmith@gnu.org>
Mon, 5 Jun 2017 00:06:48 +0000 (20:06 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 1 Jul 2017 23:40:21 +0000 (19:40 -0400)
* tests/scripts/functions/shell: Verify that .SHELLSTATUS contains
a non-0 value when the shell exits due to a signal.

function.c
tests/scripts/functions/shell

index 8d8f198f71168dd750e17ee314120a00e798dce6..92a750dc9f75f9baa268b3b11a6b1491464fb13b 100644 (file)
@@ -1469,6 +1469,9 @@ shell_completed (int exit_code, int exit_sig)
   else
     shell_function_completed = 1;
 
+  if (exit_code == 0 && exit_sig > 0)
+    exit_code = 128 + exit_sig;
+
   sprintf (buf, "%d", exit_code);
   define_variable_cname (".SHELLSTATUS", buf, o_override, 0);
 }
index 24e94ab8c22d728666b910efe377192502100735..6e446084e33e12259e014329052bfcdccac90a55 100644 (file)
@@ -22,9 +22,16 @@ $(shell exit 0)
 OK := $(.SHELLSTATUS)
 $(shell exit 1)
 BAD := $(.SHELLSTATUS)
+$(shell kill -2 $$$$)
+SIG := $(.SHELLSTATUS)
 all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
               ','','PRE= OK=0 BAD=1');
 
+run_make_test('.PHONY: all
+$(shell kill -2 $$$$)
+SIG := $(.SHELLSTATUS)
+all: ; @echo SIG=$(SIG)
+              ','','SIG=130');
 
 # Test unescaped comment characters in shells.  Savannah bug #20513
 run_make_test(q!