From 6775eb308258e81d73752e96a50f5166d6559907 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 4 Oct 2015 23:46:12 +0200 Subject: [PATCH] Fixed bug #46120: Suspend should suspend (at least local) children'. --- src/parallel | 3 +++ testsuite/tests-to-run/parallel-local4.sh | 8 ++++++++ testsuite/wanted-results/parallel-local4 | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/src/parallel b/src/parallel index 79c21c65..fef36d9f 100755 --- a/src/parallel +++ b/src/parallel @@ -3125,6 +3125,9 @@ sub save_original_signal_handler { %Global::original_sig = %SIG; $SIG{TERM} = sub {}; # Dummy until jobs really start $SIG{ALRM} = 'IGNORE'; + # Allow Ctrl-Z to suspend and `fg` to continue + $SIG{TSTP} = sub { kill "STOP", map { -$_ } keys %Global::running, $$; }; + $SIG{CONT} = sub { kill "CONT", map { -$_ } keys %Global::running, $$; }; } sub list_running_jobs { diff --git a/testsuite/tests-to-run/parallel-local4.sh b/testsuite/tests-to-run/parallel-local4.sh index 766297b0..932bbf31 100644 --- a/testsuite/tests-to-run/parallel-local4.sh +++ b/testsuite/tests-to-run/parallel-local4.sh @@ -1,5 +1,13 @@ #!/bin/bash +echo 'bug #46120: Suspend should suspend (at least local) children' + stdout bash -i -c 'stdout /usr/bin/time -f CPUTIME=%U parallel --timeout 5 burnP6 ::: 1 | grep -q CPUTIME=1 & + sleep 1.1; + kill -TSTP -$!; + sleep 5; + fg; + echo Zero=OK $?' | grep -v '\[1\]' + cat <<'EOF' | sed -e 's/;$/; /;' | stdout parallel -vj0 -k --joblog /tmp/jl-`basename $0` -L1 echo '### -L -n with pipe' seq 14 | parallel --pipe -k -L 3 -n 2 'cat;echo 6 Ln line record' diff --git a/testsuite/wanted-results/parallel-local4 b/testsuite/wanted-results/parallel-local4 index 49539996..f1cc7d33 100644 --- a/testsuite/wanted-results/parallel-local4 +++ b/testsuite/wanted-results/parallel-local4 @@ -1,3 +1,10 @@ +bug #46120: Suspend should suspend (at least local) children +2048 0a:c0:70:5b:ec:f6:c2:de:67:c3:53:7f:29:81:65:54 tange@hk (RSA1) +8192 e1:95:e3:ff:99:a6:3a:b5:53:5a:54:59:d0:72:94:7f /home/tange/.ssh/id_rsa (RSA) +4096 94:2a:e3:cb:6b:66:63:21:13:51:8d:e8:4e:09:49:b2 /home/tange/.ssh/id_rsa_openindiana (RSA) + +stdout /usr/bin/time -f CPUTIME=%U parallel --timeout 5 burnP6 ::: 1 | grep --colour=auto -q CPUTIME=1 +Zero=OK 0 echo '### -L -n with pipe' ### -L -n with pipe seq 14 | parallel --pipe -k -L 3 -n 2 'cat;echo 6 Ln line record'