From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25991 invoked by alias); 10 May 2011 17:22:11 -0000 Received: (qmail 25981 invoked by uid 22791); 10 May 2011 17:22:10 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-out.apple.com (HELO mail-out.apple.com) (17.151.62.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 17:21:56 +0000 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from relay13.apple.com ([17.128.113.29]) by mail-out.apple.com (Oracle Communications Messaging Exchange Server 7u4-20.01 64bit (built Nov 21 2010)) with ESMTPS id <0LKZ00E50PEQXJP0@mail-out.apple.com> for cygwin@cygwin.com; Tue, 10 May 2011 10:21:55 -0700 (PDT) Received: from [17.213.41.1] (Unknown_Domain [17.213.41.1]) (using TLS with cipher AES128-SHA (AES128-SHA/128 bits)) (Client did not present a certificate) by relay13.apple.com (Apple SCV relay) with SMTP id BF.04.29082.33479CD4; Tue, 10 May 2011 10:21:55 -0700 (PDT) Subject: Re: Cygwin 1.7.x on Windows 7: Exit statuses of Win32 executables are sometimes wrong From: John Dong In-reply-to: <0C817B08-1920-43DB-B9A0-26E4B2E362EA@apple.com> Date: Tue, 10 May 2011 17:22:00 -0000 Message-id: References: <0C817B08-1920-43DB-B9A0-26E4B2E362EA@apple.com> To: cygwin@cygwin.com X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-05/txt/msg00131.txt.bz2 I can still reproduce this on the latest snapshot. I also tried some different hardware and virtual machines too, and I don't think my machine is to blame. Has anyone else been able to reproduce this bug? Or have pointers of further things I can do to diagnose it? Thanks in advance, John On Apr 29, 2011, at 11:35 AM, John Dong wrote: > Hi, > > Cygwin on Windows 7, seems to exhibit a rather peculiar behavior: Sometimes the exit status of a Win32 process is incorrectly captured by Cygwin. > > I'm running Cygwin 1.7.9(0.237/5/3) on Windows 7 64-bit, but I've reproduced this behavior with every release of Cygwin 1.7 on both 32-bit and 64-bit Windows 7. It does not seem to happen in XP 32-bit, and I've not tried any other environments. > > > To reproduce, first I wrote a Win32 console application (using Visual Studio 2010 / cl.exe version 16 as my compiler) that exits with the status the user passes in: > >> int _tmain(int argc, _TCHAR* argv[]) >> { >> int ret = _ttoi(argv[1]); >> _tprintf(_T("Exiting with %i\n"), ret); >> >> return ret; >> } > > > Then, I wrote a shell script that called this executable ("exiter.exe") with argument 0 in an infinite loop: > >> #!/bin/sh >> set -e >> while true; do >> /cygdrive/c/exiter.exe 0 >> echo $? >> done >> > > I expect this script to run forever, as the exit code should always be zero. However, after running this overnight, I see the script terminate: > >> Exiting with 0 >> 0 >> Exiting with 0 >> 0 >> Exiting with 0 >> 0 >> Exiting with 0 >> 0 >> Exiting with 0 >> >> $ echo $? >> 1 >> > > > > The last line of output implies that exiter.exe executed "return 0", but /bin/sh saw a nonzero exit status (of 1) and thus stopped execution due to -e. > > Reproducing this seems nondeterministic -- sometimes I can get it to happen in 5 minutes, other times it takes overnight. I've tried using a different shell (like dash), but it doesn't make a difference, leading me to suspect this to be a lower-level issue within the Cygwin DLL. It also seems to not happen for non-zero exit codes (e.g. checking that exiter.exe 1 returns 1 always seems to succeed), though I'm not 100% confident that I've tested this thoroughly enough. > > Again, I've not been able to reproduce this under Windows XP using any version of Cygwin, but I have been able to reproduce it on both 32-bit and 64-bit Windows 7. I'm not running anything special on this machine -- it's a fresh install of Windows 7 Professional, just with Cygwin installed. > > > Thanks in advance, > > John > > > -- > 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 > -- 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