delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/02/03/12:13:47

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
q=dns; s=default; b=HsPv5AkHTSxEkwL8+bhp3lpjc+thpUtgLm4q8Ub0t7y
P/aJdu2FuBC/yurfSpRBitnhfWylvHDrgQZ0Vird022+jBBOYgToXpmhVbY3AQlM
3IavlYk58N4DTFiwnk2Ib0GJcA85a8gmbVJY7tLGOriz9kYL3GyxvqyWnziW/dsA
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
s=default; bh=OwplewX52sDxrDpza6mRUwD6PRc=; b=C4GdN0FyGc6m74Nc6
96+qyeAZDuLooyssCNBtvW8NQddE+0gLDsXubPBKOM+Ib36QXnE7vU3SQhrbsLWI
QWjVZ8JRd3167SA1oAeY3mbztCc5JQ9VPa9yqoXvYA49RzAmOXFrTG+SrMy7btT8
2K3e8KYnlKmm5KBiGowkUDDPkI=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2
X-HELO: na01-by2-obe.outbound.protection.outlook.com
Message-ID: <52EFCE2E.4060003@coverity.com>
Date: Mon, 3 Feb 2014 12:13:18 -0500
From: Tom Honermann <thonermann AT coverity DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version: 1.0
To: <cygwin AT cygwin DOT com>
Subject: Re: sh.exe returns incorrect exit code
References: <3e7d738f-a4e5-4407-aafe-a54f70eb72e2 AT default>
In-Reply-To: <3e7d738f-a4e5-4407-aafe-a54f70eb72e2@default>
X-ClientProxiedBy: BL2PR08CA013.namprd08.prod.outlook.com (10.141.66.33) To BY2PR05MB598.namprd05.prod.outlook.com (10.141.219.19)
X-Forefront-PRVS: 01110342A5
X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009001)(6009001)(6049001)(24454002)(479174003)(377454003)(199002)(189002)(51704005)(47736001)(47976001)(86362001)(49866001)(63696002)(65806001)(50986001)(4396001)(74876001)(93516002)(80022001)(65956001)(92726001)(80976001)(36756003)(54356001)(66066001)(47776003)(81542001)(94316002)(15202345003)(74662001)(76482001)(33656001)(56776001)(53806001)(50466002)(42186004)(81816001)(54316002)(74706001)(93136001)(59896001)(69226001)(77096001)(76786001)(15975445006)(87976001)(76796001)(85306002)(83072002)(90146001)(74366001)(94946001)(81686001)(83506001)(19580395003)(46102001)(64126003)(79102001)(56816005)(47446002)(23756003)(31966008)(51856001)(77982001)(74502001)(81342001)(80316001)(92566001)(85852003)(83322001)(59766001)(21314002)(460985004)(2480315003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR05MB598;H:[192.168.1.7];CLIP:96.253.80.174;FPR:AED1F015.B2D2AFD9.C1D0174F.44D8EBBC.2041D;InfoNoRecordsA:1;MX:1;LANG:en;
X-OriginatorOrg: coverity.com
X-IsSubscribed: yes

On 01/31/2014 03:11 PM, Darrel Laursen wrote:

Hey Darrel!  Nice to see you popping up here!

> Below is the relevant process tree.
>
> make.exe (PID=77256) launches sh.exe -c "pscl.exe . || (shopt -s nullglob && rm -f xxx.obj; exit 1)"
> +--- sh.exe (PID=94584) launches sh.exe <no command line given>
>       +--- sh.exe (PID=32240) launches pscl.exe .
>            +--- pscl.exe (PID=135060-a Win32 executable) launches a bunch of subprocesses .
>            +--- pscl.exe (PID=135060) exits with errorlevel 0
>       +--- sh.exe (PID=32240) exits with errorlevel 32256 (0x7E00)
> +--- sh.exe (PID=94584) launches sh.exe <no command line given>
>       +--- sh.exe (PID=84604) launches sh.exe <no command line given>
>            +--- sh.exe (PID=156240) launches rm.exe -f xxx.obj
>                 +--- rm.exe (PID=884) runs
>            +--- sh.exe (PID=156240) exits with errorlevel 0
>                 +--- rm.exe (PID=884) exits with errorlevel 1
>       +--- sh.exe (PID=84604) exits with errorlevel 256
> +--- sh.exe (PID=94584) exits with errorlevel 1
> make.exe exits with errorlevel 2
>
> The errorlevel 32256 (0x7E00) returned by PID 32240 (the forked copy
> of sh.exe) is bogus. Any idea what errorlevel 32256 means between
> sh.exe and its forked copy of itself? I don't really know how to
> check this further. I'm hoping someone can help me determine what
> this return code represents and why the forked copy of sh.exe would
> return it.
>
> I can see how fork() starts a second copy of the same cygwin
> executable (for sh.exe at least). There appears to be some special
> return code numbering system between sh.exe and the forked child copy
> of itself. Later another forked copy of sh.exe (PID=84604) exits with
> code 256 and the parent copy of sh.exe (PID=94584) translates this to
> its own exit code of 1 which is the correct final value for that
> situation. In other parts of the process tree not shown here I can
> see the forked sh.exe exits with 512 and the parent sh.exe correctly
> translate this to its own exit code 2. If the cygwin/sh.exe protocol
> is for the parent to take the forked copy's exit code and right shift
> it 8 bits, then this means a forked exit code of 0x7E00 translates to
> a real exit code of 0x7E (0n126). Does exit code 126 correspond with
> some internal sh.execoncept?

sh exit code 126 is documented by POSIX [1] to indicate that a command 
specified a (non-builtin) utility to run, that a file matching the name 
was found, but that the file was not executable.

The process tree above doesn't appear to match that exit code 
description however.

I would suspect [2], but if I remember correctly, pscl.exe is not 
multi-threaded.

I presume the process tree above was captured from your native build. 
Have you been able to reproduce the issue in a smaller test case?  For 
example, I'm running the following right now to see if I can provoke a 
similar failure (note that this invokes Microsoft's cl.exe (from VS 
2010) instead of pscl.exe).  I'm also running GNU bash 4.1.10(4)-release 
(on Cygwin 1.7.23-1).  Perhaps you can try this with pscl.exe?

$ cat doit.sh
#!/bin/sh

while [ 1 ]; do
   make || {
     echo "make failed unexpectedly"
     break
   }
done

$ cat Makefile
all:
         cl.exe /c t.cpp || (shopt -s nullglob && rm -f t.obj; exit 1)

$ cat t.cpp
int i;

Tom.

[1]: 
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02
[2]: http://support.microsoft.com/kb/2875501

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

- Raw text -


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