From: John Dong <jdong@apple.com>
To: cygwin@cygwin.com
Subject: Cygwin 1.7.x on Windows 7: Exit statuses of Win32 executables are sometimes wrong
Date: Fri, 29 Apr 2011 20:01:00 -0000 [thread overview]
Message-ID: <0C817B08-1920-43DB-B9A0-26E4B2E362EA@apple.com> (raw)
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
next reply other threads:[~2011-04-29 18:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 20:01 John Dong [this message]
2011-04-30 11:30 ` Edward McGuire
2011-04-30 13:23 ` John Dong
2011-05-02 17:18 ` John Dong
2011-05-10 17:22 ` John Dong
2011-05-25 14:16 ` Edward Lam
2011-05-25 14:20 ` Christopher Faylor
2011-05-26 2:20 ` John Dong
2011-05-26 5:47 ` Christopher Faylor
2011-05-26 6:02 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0C817B08-1920-43DB-B9A0-26E4B2E362EA@apple.com \
--to=jdong@apple.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).