bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] system() should return != 0 when the process is killed


From: Stephane Chazelas
Subject: Re: [bug-gawk] system() should return != 0 when the process is killed
Date: Thu, 10 Mar 2016 21:45:42 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

2016-03-10 22:33:19 +0200, Aharon Robbins:
> Hi. Re this:
[...]
> Brian Kernighan may adjust his awk, or he may not. I've sent him
> diffs to do exit value / 256 + signal, but I don't yet whether or
> not he will incorporate the changes.
[...]

So why not doing the same thing as mawk here (see my other
posts)? It seems better to me as it would consistent with
shells' $? at least when no core is dumped.

If you return 256+signal and the user passes that to exit(), $?
in the shell will become "signal". If you make it 128+signal,
and call exit on it, then the shell's $? will be 128+signal,
that is for most shells (yash and ksh93 being the exceptions),
the same as what $? would be for a process killed by that same
signal.

A possible improvement over mawk would be to make it 128+signal,
and if a core was dumped, add another 256, instead of another
128 like mawk does.  That way, if the user passes that to exit,
$? in the shell will still be 128+signal, like it would be for a
process killed by that signal (with or without core dump) and
the awk code can tell if a core was dumped.

Also, again, close() also needs to be addressed as well.
And again, returning the same value as for system() like mawk
does is what makes most sense to me.

-- 
Stephane




reply via email to

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