bug-gnulib
[Top][All Lists]
Advanced

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

Re: getopt-gnu: fix exit code overflow


From: Eric Blake
Subject: Re: getopt-gnu: fix exit code overflow
Date: Tue, 19 Jun 2012 05:32:47 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

On 06/19/2012 04:11 AM, Bruno Haible wrote:
> Exit codes are limited to be < 128. Values between 128 and 255 are reported
> as core dumps by the invoking shell.

Not true.  waitpid() distinguishes between normal exits > 128 and a
signal exit, and all existing shells are good about only reporting core
dumps or other signal exits when waitpid() says the child exits via
signal.  It's just the ambiguity that results when dealing with $? after
the fact, if you are trying to analyze the failure; and for this
particular .m4 snippet, the chance of a signal is so slim that we are
safe analyzing values > 128.

Furthermore, POSIX permits, and ksh implements, the ability to report
signal exits in the range > 255 while still within the shell (only
mapping $? back to 128-255 when leaving the shell), so that it is
possible to distinguish in shell whether $? represents a signal or a
normal exit.

> To avoid such misinterpretations,
> this fix. The problem was introduced on 2011-07-07.

ACK to this fix, at any rate.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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