delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/08/23/02:20:23

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <A7E3A4B51615D511BCB6009027D0D18C05F1D4A4@aspams01.ca.com>
From: "Reddie, Steven" <Steven DOT Reddie AT ca DOT com>
To: cygwin AT cygwin DOT com
Subject: 1.3.12: Process exit code's shifted up 8 bits (cwait, wait, waitp
id)
Date: Fri, 23 Aug 2002 16:20:16 +1000
MIME-Version: 1.0

There appears to be a bug in cwait and I think in other functions (wait,
waitpid) in that the exit code of the child process is shifted up 8 bits.
Some sample code:

#include <stdio.h>
#include <process.h>

void main()
{
        char* args[] = { "cl", "/c", "foo.c", NULL };

        int pid = spawnvp(_P_NOWAIT, args[0], args);
        if (pid != -1)
        {
                int     result = 0;
                cwait(&result, pid, WAIT_CHILD);
                printf("result = %d\n", result);
        }
}

Output from Cygwin gcc compile (gcc -ox.exe x.c):
	result = 512
Output from MSVC compile (cl x.c):
	result = 2

The reason I say that I think it is also in wait or waitpid is that I saw
something similar when I was playing around with fork but I don't recall the
details.

Can someone please let me know if this isn't expected behaviour.  If it is a
bug I need to work around it in such a way that when it gets fixed my code
doesn't break.  I guess I could shift the value down 8 bits only if is is
greater than 255.  Does that sound like the best approach?

Steven
--
Steven Reddie <Steven DOT Reddie AT ca DOT com>
Senior Software Engineer
Computer Associates Pty Ltd (Australia)


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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