This is the mail archive of the
mailing list for the Cygwin project.
Fw: 1.5.11 bug in WEXITSTATUS() macro (wait.h)
- From: "Peter Dons Tychsen" <donpedro at tdcadsl dot dk>
- To: <cygwin at cygwin dot com>
- Date: Sat, 25 Sep 2004 20:45:33 +0200
- Subject: Fw: 1.5.11 bug in WEXITSTATUS() macro (wait.h)
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
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)
#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. :-)
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.737 / Virus Database: 491 - Release Date: 11-08-2004
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html