]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* tests/scripts/functions/shell: Detect correct SHELLSTATUS code.
authorPaul Smith <psmith@gnu.org>
Sat, 21 Sep 2019 18:01:19 +0000 (14:01 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 21 Sep 2019 19:13:32 +0000 (15:13 -0400)
tests/scripts/functions/shell

index 3ffa1d8d6f437f42a120e2dc980aa89f26992958..54514e832789371bc8cb12fd272cb6381393ce4c 100644 (file)
@@ -61,11 +61,21 @@ all: ; @echo $(.SHELLSTATUS)
 
     # Test SHELLSTATUS for kill.
     # This test could be ported to Windows, using taskkill ... ?
+
+    # Figure out the exit code for SIGINT
+    my $pid = fork();
+    if (! $pid) {
+        exec('kill -2 $$') or die "exec: Cannot execute sleep\n";
+    }
+    waitpid($pid, 0);
+    # .SHELLSTATUS for a signal gives 128 + the signal number
+    my $ret = $? + 128;
+
     run_make_test('.PHONY: all
 $(shell kill -2 $$$$)
-SIG := $(.SHELLSTATUS)
-all: ; @echo SIG=$(SIG)
-              ','','SIG=130');
+STAT := $(.SHELLSTATUS)
+all: ; @echo STAT=$(STAT)
+              ','',"STAT=$ret\n");
 }
 
 1;