delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/08/13:11:31

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 8 Jul 2004 19:13:35 +0200 (W. Europe Daylight Time)
From: Daniel Lungu <lungu AT nagra DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: negative error status: gcc vs. cl
In-Reply-To: <Pine.WNT.4.21.0407081106020.247-100000@pc0197.nagra-kudelski.ch>
Message-ID: <Pine.WNT.4.21.0407081839590.215-100000@pc0197.hq.k.grp>
X-X-Sender: lungu AT castor DOT hq DOT k DOT grp
MIME-Version: 1.0

:) "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."

It is exactly what happens when compiling nerr.c with gcc:

-----unsigned-8b-exit-status-----
% nerr-gcc.exe; echo $?
254

sizeof (int) = 4 [B] on i686

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

Indeed, but same arithmetic should apply when exit status comes from a "cl
compiled .exe". It is not the case when compiling nerr.c with cl:

-----wrong-nil(!)-exit-status-----
% nerr-cl.exe; echo $?
0

$? cannot distinguish exit(0) from exit(-2) ... this is logical anarchy! One
cannot reliably test exit status of legacy windoze binaries.

:)    cheers, 
:)      DaveK

ksh :) yields the same Cygwin bug. Thanks for answers. Daniel.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019