parallel
[Top][All Lists]
Advanced

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

Re: parallel can not handle signals correctly


From: Ole Tange
Subject: Re: parallel can not handle signals correctly
Date: Mon, 12 Feb 2018 20:13:27 +0100

On Mon, Feb 12, 2018 at 5:56 PM, Peng Yu <address@hidden> wrote:
> 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

I can reproduce this.

> 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

I get:

^C3
1
4
2
5
7
8
6

when run on an 8-core machine.

Can you reproduce your result on a VirtualBox
(https://www.gnu.org/software/parallel/man.html#REPORTING-BUGS)?


/Ole



reply via email to

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