Re: How to report a death by signal ?

From: Olivier Brunel <jjk_at_jjacky.com>
Date: Wed, 18 Feb 2015 14:55:54 +0100

On 02/18/15 14:20, Laurent Bercot wrote:
> On 18/02/2015 14:04, Olivier Brunel wrote:
>> I don't follow, what's wrong with using a fd?
>
> It needs a convention between G and P. And I can't do that, because
> G and P are not necessarily both execline commands. They are normal
> Unix programs, and the whole point of execline is to have commands
> that work transparently in any environment, with only the Unix argv
> and envp as conventions.

But isn't the whole anything >= 128 will be reported as 128, and
anything higher is actually 128+signum also a convention that both needs
to agree upon?

P will "do something" to report info about C to G, and P and G needs to
agree about how said info will be reported. Using 128+signum is one way,
using an fd for the full/correct info is another.

The later being an option, it wouldn't change what P returns, but be an
additional means to provide accurate information to grandprocess G
should they need to.
Or just, like shells, assume it's not needed and simply only do the
128+signum convention.

Noting that shells do not actually clamp the exit code to 128. As
illustrated by Peter's example, shells return the exit code (up to 255
included), or 128+signum.
So assuming no signal, you get the accurate exit code. But of course,
with anything higher than 128 there's no way of knowing if it was an
exit code or a signal (unless you know exit codes don't go that high).
(Clamping provides better results though, so I'm not saying don't do it;
Just the difference shall probably be pointed out/documented.)


>> Cause that was my idea as well: return the exit code or 255.
>
> I was considering it for a while, then figured that the signal number
> is an interesting information to have, if G remotely cares about
> C crashing. I prefer to reserve the whole range of 128+ for
> "something went very wrong, most likely a crash at some point, and
> if you get 129+, it was directly below you and you get the signal
> number".
>
>
>> Though if you want "shell compatibility" you could also have an option
>> to return exit code, or 128+signum when signaled, and similarly one
>> would either be fine with that, or have to use the fd for full/complete
>> info.
>
> Programs that can establish a convention between one another are easy
> to deal with. If I remember to document the convention (finish scripts
> *whistle*)
>
Received on Wed Feb 18 2015 - 13:55:54 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC