bug-coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] Fix exit status of signal handlers in shell scripts


From: Eric Blake
Subject: Re: [PATCH] Fix exit status of signal handlers in shell scripts
Date: Sat, 30 Jan 2010 12:28:50 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

According to Dmitry V. Levin on 1/30/2010 12:18 PM:
> The value of `$?' on entrance to signal handlers in shell scripts
> cannot be relied upon, so set the exit code explicitly to
> 128 + SIGTERM == 143.
> * src/Makefile.am (sc_tight_scope): Use `exit 143' in signal handler.

I'm not sure I like the direction this is headed in.  Exiting with 143
when a trap is known to be caused by SIGTERM might be okay, but it would
be even better to reraise the signal and make the shell also exit by
SIGTERM (in case the caller can distinguish between exit by signal and
normal exit by status > 128).  But blindly giving status 143 for other
signals, like SIGHUP, is just wrong.  If you are going to munge trap
handlers to account for races, then you need one trap handler per signal
with an appropriate exit status for each.

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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