[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SIGINT handling
From: |
Stephane Chazelas |
Subject: |
Re: SIGINT handling |
Date: |
Tue, 22 Sep 2015 19:20:15 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2015-09-22 12:04:45 -0600, Bob Proulx:
> Greg Wooledge wrote:
> > Just for the record, ping is the *classic* example of an incorrectly
> > written application that traps SIGINT but doesn't kill itself with
> > SIGINT afterward. (This seems to be true on multiple systems -- at
> > the very least, HP-UX and Linux pings both suffer from it.)
>
> The command I run into the problem most with is 'rsync' in a loop.
>
> EXIT VALUES
> 0 Success
> ...
> 20 Received SIGUSR1 or SIGINT
>
> Which forces me to write such things this way.
>
> rsync ...
> rc=$?
> if [ $rc -eq 20 ]; then
> kill -INT $$
> fi
> if [ $rc -ne 0 ]; then
> echo "Error: failed: ..." 1>&2
> exit 1
> fi
[...]
Another (generic) work-around as mentioned at
http://unix.stackexchange.com/a/230568
and here is to add:
trap '
trap - INT
kill -s INT "$$"
' INT
That doesn't work properly if there are subshells though.
That basically turns a WCE shell to WUE (for very simple scripts).
For SIGQUIT, you'd probably want to disable core dumps as well:
trap '
trap - QUIT
ulimit -c 0
kill -s QUIT "$$"
' QUIT
--
Stephane
- Re: SIGINT handling, (continued)
- Re: SIGINT handling, Stephane Chazelas, 2015/09/20
- Re: SIGINT handling, Stephane Chazelas, 2015/09/20
- Re: SIGINT handling, Stephane Chazelas, 2015/09/20
- Re: SIGINT handling, Chet Ramey, 2015/09/21
- Re: SIGINT handling, Stephane Chazelas, 2015/09/21
- Re: SIGINT handling, Stephane Chazelas, 2015/09/22
- Re: SIGINT handling, Stephane Chazelas, 2015/09/22
- Re: SIGINT handling, Greg Wooledge, 2015/09/22
- Re: SIGINT handling, Stephane Chazelas, 2015/09/22
- Re: SIGINT handling, Bob Proulx, 2015/09/22
- Re: SIGINT handling,
Stephane Chazelas <=
- Re: SIGINT handling, Chet Ramey, 2015/09/24
- Re: SIGINT handling, Chet Ramey, 2015/09/24
- Re: SIGINT handling, Chet Ramey, 2015/09/23
- Re: SIGINT handling, Chet Ramey, 2015/09/23
- Re: SIGINT handling, Stephane Chazelas, 2015/09/24
- Re: SIGINT handling, Stephane Chazelas, 2015/09/24
- Re: SIGINT handling, Pádraig Brady, 2015/09/24
- Re: SIGINT handling, Stephane Chazelas, 2015/09/24
- Re: SIGINT handling, Stephane Chazelas, 2015/09/24
- Re: SIGINT handling, Chet Ramey, 2015/09/24