X-Recipient: archive-cygwin@delorie.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:mime-version:date:message-id:subject:from:to
	:content-type; q=dns; s=default; b=B99m0hjyHGqWgYBRc5FiwH1lkL0y3
	xketNGcJYvAp56094SjztWWYYjIwi/QlAxdo6eYIh+ION9I/k0c91xHu3YPewIiD
	bfzdw9nKPSpYGUZewqbfhBQootnGYr7F/0bgWVcr52FU1ZDFnxXBR/R3HfXdEhtM
	i0679ACFuSfvD4=
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:mime-version:date:message-id:subject:from:to
	:content-type; s=default; bh=A9fXsS7sC4C2XjShYsBD4pOzLZc=; b=vCX
	DIucbQhVFSEeBwMvDQw1Rv6NnG/ouTqPvlHx2kPTl4SADLn0GrixVVtdHmDFSMx3
	XNLDdjTnytvRsInWqf7MbQFcSXe2Mn0CZETFSfeS/9bquKBZ77etkfiJ/Jubr0Yo
	B64YP++2z/75xLvv1Hgabow1Y7k4UMV+Vpbh2rLM=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=FAQs, exe, randomly, Hx-languages-length:2288
X-HELO: mail-lb0-f181.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=1e100.net; s=20130820;        h=x-gm-message-state:mime-version:date:message-id:subject:from:to         :content-type;        bh=zKFDuqCwzR3PGtqTzu4ov5qfpGdRMi9FgaMiM4qkK3Y=;        b=VnJuJRr6iuB2D6QwXkXTnWQ6eoxTX7dK7SJ2gzdGmSrC7yAUGRN6JdVom1aTqv2BrT         ipXGP70lcrsAE8iE2//6csoRGoZxIzYT9+TPULduzHKJhEsJVjnFQXYHpbmR+SdNChMG         WooQbQlMLLLHWX2JFXtDT6oaVXsF13/L/SxdHcBIyGTZfaGBShwzwWDUdXXVBizehxoK         ety/JmAI4QKol51k0YGHfaAVdrcFWVl/zEFZaqkRHFx2Ser0klhe3htlla0QECb0k+zu         X0Kuk+EyrqEIicfoXlY3bOEYHRI1qkROdqRSrBY0uncN5SjwgCXAyMbYE5NMxBLamdIh         kgdQ==
X-Gm-Message-State: ALoCoQlTOD18pyqnjuMq5UWgdvPn50V4PoboEk9mhkBYJi3krTZwfRuu5jrQ9nFclzp8vzY9Hqqejd3xHn9lkOhoX/T3ulVf9Q==
MIME-Version: 1.0
X-Received: by 10.112.173.164 with SMTP id bl4mr7052966lbc.144.1453130859398; Mon, 18 Jan 2016 07:27:39 -0800 (PST)
Date: Mon, 18 Jan 2016 10:27:39 -0500
Message-ID: <CAGW0ud2ELnAAkx57A3LutxiAoBtv1Mm7ssfaut__JDJu5GUSkg@mail.gmail.com>
Subject: Running native exe from Cygwin in random instances reports incorrect error code 127
From: David Sicilia <dpsicilia@gmail.com>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=UTF-8

Hi there,

I have a strange problem for which I could not find any help online or
in the Cygwin FAQs (have been searching for about a month now).  I
have Cygwin64 on Windows 7 (downloaded maybe about 8 months ago).

I have a bash script that, in addition to running Cygwin programs,
runs a few native Windows executables (e.g. powershell.exe, windows
python.exe, some C++ binary that I've compiled for Windows [not
cygwin], etc.).

This works fine normally, except in random instances (I'd say it
happens maybe one out of every 30 runs), I observe the following:

   1) The Cygwin bash script runs the native executable
   2) The executable is properly located by bash and begins to run
(i.e., I can see output from the native windows program)
   3) The native windows program successfully completes and exits with
code 0 internally
   4) But -- the error code returned to the bash script is 127 --
despite no indication of an error anywhere

Here's an example:

  #!/bin/bash
  # Run windows binary
  # program is properly located and runs to completion with no errors
  ./nativeWindowsProgram.exe
  echo $?   # maybe 1 out of 30 times this returns 127
  127

This only happens with native binaries, including with one of my own
compiled (from C++) native windows .exe files in which I know for
certain that it is returning a zero error code.

So in other words, the bash script, despite having located and run the
native windows exe successfully, is still handed an error code of 127.
I realize that 127 usually means "Command not found" but that is not
the case here, because the native program always runs, and always runs
successfully (I verified this).

This happens randomly -- today I run the script a few times and it's
fine, then tomorrow I run it a few times (unchanged) and I observe
this issue on one of those runs.  Furthermore, it only happens when
running the native windows binaries in the shell script (never happens
for Cygwin programs).

This is really mystifying me, I've searched all over but I can't find
anything.  Does anyone have any idea?  I could always setup my bash
script to ignore the 127 return code from invocations of native exes,
but I'd prefer to get to the bottom of it.  Any ideas?

Thank you

--
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

