parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

parallel can not handle signals correctly


From: Peng Yu
Subject: parallel can not handle signals correctly
Date: Mon, 12 Feb 2018 10:56:59 -0600

Hi,

Here is the behavior of a normal bash script. If I type ctrl-c, it
will terminate the program. But it will also trigger the EXIT trap
which print "1".

---------------
$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

function cmd {
#echo $1
trap "echo $1" EXIT
}

cmd 1
sleep 5
$ ./script.sh
^C1
---------------

But when I run it with parallel, the signals will not be triggered by
ctrl-c. Should this be considered as a bug?

---------------
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

code=$(
cat <<'EOF'
function cmd {
#echo $1
trap "echo $1" EXIT
}
EOF
)

set -v
seq 12 | parallel "$code; cmd {}; sleep 5"
$ ./main.sh
seq 12 | parallel "$code; cmd {}; sleep 5"
^C


-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]