negative error status: gcc vs. cl

Dave Korn
Thu Jul 8 12:01:00 GMT 2004

> -----Original Message-----
> From: cygwin-owner On Behalf Of Corinna Vinschen
> Sent: 08 July 2004 11:09

> On Jul  8 11:49, Daniel Lungu wrote:
> > Feel like bash tcsh on Cygwin mess up with negative exit 
> status from a cl
> > compiled .exe
> The answer is "don't do that".  Use positive values in the range from
> 0 to 255.  See

  Well, according to that page, the answer is 'you may do that':

"The value of status may be 0, EXIT_SUCCESS, EXIT_FAILURE, [CX]   or any
other value"

but what you shouldn't do is expect the exit status in the shell to be
anything other than the least-significant byte of the value you passed:

"though only the least significant 8 bits (that is, status & 0377) shall be
available to a waiting parent process."

  So -2 comes back as 254.  Sounds like perfectly correct 2's complement
arithmetic to me!

Can't think of a witty .sigline today....

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list