[Toybox] default SIGPIPE handler that calls _exit(0)?

enh enh at google.com
Mon Apr 27 18:12:27 PDT 2015


On Mon, Apr 27, 2015 at 12:56 PM, Rich Felker <dalias at libc.org> wrote:
> On Mon, Apr 27, 2015 at 12:39:15PM -0700, enh wrote:
>> >> plus there's the question of whether giving up because you're writing
>> >> to a broken pipe is an error exit or not. you could add a special case
>> >> to xwrite (and add xprintf and xputs and...), but since the whole idea
>> >> is that code shouldn't have to care, it's easier just to install a
>> >> signal handler that does _exit(0).
>> >
>> > There are xputs and xprintf already.
>> >
>> > Calling _exit() is wrong for toybox, since you cannot use atexit()
>> > type code (eg, delete tempfiles on exit) - xexit() is the recommended
>> > path for toybox.
>> > Using a fixed return value is wrong; for an example, grep returns
>> > 0 for "line matched", 1 for "no match", and >1 for errors.
>>
>> (GNU grep 2.16 thinks grep should just die with SIGPIPE.)
>
> I'm perfectly fine with any result that's properly distinguishable
> from result code with defined meanings -- especially 0 (success) and
> in the case of grep 1 (successful run with no match). It's probably
> wrong for Android to be treating SIGPIPE as a crash to begin with.

it's certainly inconsistent that SIGALRM isn't. i think the problem is
that we don't have a good way to distinguish "apps" from command-line
tools. (and which would a command-line tool run from an app be
anyway?) it doesn't matter for Java, because there it's the system's
job to turn broken pipes into thrown exceptions. but that just means
Android developers are expecting SIGPIPE even less.

it's still very tempting though.

-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1430183547.0


More information about the Toybox mailing list