[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix exit status of signal handlers in shell scripts
From: |
Bruno Haible |
Subject: |
Re: [PATCH] Fix exit status of signal handlers in shell scripts |
Date: |
Sun, 31 Jan 2010 12:32:06 +0100 |
User-agent: |
KMail/1.9.9 |
Ralf Wildenhues asked:
> What system and shell (version?) were your tests done on?
I could reproduce Dmitry's tests, with 'sleep 1' instead of 'sleep 0.01'.
$ for i in `seq 0 9`; do sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done' & pid=$! && sleep 1 && kill -TERM -$pid && wait $pid; done
[1] 29718
Beendet
[1]+ Exit 143 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 29968
Beendet
[1]+ Exit 143 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 30546
[1]+ Exit 1 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 31188
Beendet
[1]+ Exit 143 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 31867
[1]+ Done sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 32547
[1]+ Exit 1 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 764
Beendet
[1]+ Exit 143 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 1406
Beendet
[1]+ Exit 143 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 2060
[1]+ Done sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
[1] 2751
Beendet
[1]+ Exit 143 sh -c 'trap "exit \$?" TERM; while /bin/true; do
/bin/false; done'
$ uname -srm
Linux 2.6.25.20-0.5-default x86_64
$ sh -c 'echo $BASH_VERSION'
3.2.39(1)-release
> What are the "other cases" you mention, where no process was terminated
> by the signal, but the signal delivered somewhere nonethess?
When I run
$ while /bin/true; do /bin/true; done
and I want to interrupt it with Ctrl-C, sometimes I have to press Ctrl-C twice:
$ while /bin/true; do /bin/true; done
^C
$ while /bin/true; do /bin/true; done
^C^C
Similarly with a 'trap' handler installed:
$ (trap 'echo caught SIGINT; exit 130' 2; while /bin/true; do /bin/true; done)
^Ccaught SIGINT
$ (trap 'echo caught SIGINT; exit 130' 2; while /bin/true; do /bin/true; done)
^C^Ccaught SIGINT
Bruno
- Re: [PATCH] Fix exit status of signal handlers in shell scripts, (continued)