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: Aharon Robbins
Subject: Re: [bug-gawk] system() should return != 0 when the process is killed
Date: Fri, 11 Mar 2016 10:20:39 +0200
User-agent: Heirloom mailx 12.5 6/20/10

> To: address@hidden
> From: Stephane Chazelas <address@hidden>
> Date: Thu, 10 Mar 2016 21:45:42 +0000
> Subject: Re: [bug-gawk] system() should return != 0 when the process is
>       killed
>
> So why not doing the same thing as mawk here (see my other
> posts)?

Because it's not right. Ignoring the fact that mawk dies upon
receipt of a signal, here is what mawk returns. This is from the
original mawk-1.3.3, function wait_for() in files.c

|   if (exit_status & 0xff)  exit_status = 128 + (exit_status & 0xff) ;
|   else         exit_status = (exit_status & 0xff00) >> 8 ;

In Thomas Dickey's most recent version, the code is the same modulo formatting:

|    if (exit_status & 0xff)
|       exit_status = 128 + (exit_status & 0xff);
|    else
|       exit_status = (exit_status & 0xff00) >> 8;

A status of 128 + 2 for SIGINT is indistinguishable from a process that
did exit(130).

> That way, if the user passes that to exit,

It's up to the user to be careful what they return. It's not up to
me to worry about it. I can add some doc warning that using the
value directly as awk's exit status isn't a good idea.

> Also, again, close() also needs to be addressed as well.

Not related.  Gawk's behavior is documented: the return value from
pclose or from close, respectively.

> And again, returning the same value as for system() like mawk
> does is what makes most sense to me.

You're entitled to your opinion.

I will be pushing changes to the repo shortly. I consider this discussion
to be closed.

Thanks,

Arnold



reply via email to

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