delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/25/15:31:38

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: Sat, 25 Sep 2004 15:31:33 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Peter Dons Tychsen <donpedro AT tdcadsl DOT dk>
cc: cygwin AT cygwin DOT com
Subject: Re: Fw: 1.5.11 bug in WEXITSTATUS() macro (wait.h)
In-Reply-To: <00f001c4a32f$d724a570$0200000a@donpedro>
Message-ID: <Pine.GSO.4.61.0409251528570.630@slinky.cs.nyu.edu>
References: <00f001c4a32f$d724a570$0200000a AT donpedro>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Sat, 25 Sep 2004, Peter Dons Tychsen wrote:

> Hello.
>
> The WEXITSTATUS is a bit buggy. (wait.h)
>
> The macro extracts information gained from a call to waitpid() (and others).
> The information it extracts is the status of the completed process (8 bit
> signed value).
>
> The problem is that the macro does not cast the value to a signed integer
> (like other systems do), which can cause the value to be incorrectly
> interpreted (breaks some programs).
>
> The following fails:
>
> // Wait for processes to complete
> if(waitpid(pid, &status, 0) == pid)
> {
>   // Check return value for failure (-1)
>   if(WEXITSTATUS(status) == -1)
>   {
>     /* We will never get here, as the macro returns 255 if the process exited with -1 */
>   }
> }
>
> The problem can be fixed by changing the macro from:
>
> #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
>
> To:
>
> #define WEXITSTATUS(w) ((signed char)(((w) >> 8) & 0xff))
>
> It is kind of weird that no one has discovered this boo-boo before :-(
> Hope it is not me who is boo-boo. :-)
>
> /Peter

This was reported back in July.  Google for '"negative exit status"
site:cygwin.com' for the full thread.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

--
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