public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Kaz Kylheku (Cygwin)" <743-406-3965@kylheku.com>
To: moss@cs.umass.edu
Cc: Jay K <jayk123@hotmail.com>, cygwin@sourceware.org
Subject: Re: ExitProcess does not work in Cygwin?
Date: Thu, 13 Jan 2022 09:07:50 -0800	[thread overview]
Message-ID: <72e0f0601676717a2702ff13beb45b80@mail.kylheku.com> (raw)
In-Reply-To: <1f98eb84-e3d7-bf0d-875c-3d4818e41aef@cs.umass.edu>

On 2022-01-13 05:40, Eliot Moss wrote:
> On 1/13/2022 1:39 AM, Jay K wrote:
>> ExitProcess does not work in Cygwin?
> 
> ExitProcess does not appear to be a POSIX function.

This is a real issue worth looking into. Though ExitProcess isn't a 
POSIX
function, Cygwin can capture the termination status of non-Cygwin 
programs.

The concept of termination status cannot be entirely walled off in a
private Cygwin garden; it belongs to the underlying platform.

In Cygwin, I can do this:

   C:\Cygwin\cygwin64\home\kaz>exit 1
   1:BLACKBOX:~$
   1:BLACKBOX:~$ echo $?
   1
   0:BLACKBOX:~$ cmd
   Microsoft Windows [Version 10.0.19042.1052]
   (c) Microsoft Corporation. All rights reserved.

   C:\Cygwin\cygwin64\home\kaz>exit 0
   0:BLACKBOX:~$

The number in my Bash prompt is the last exit code. As you can see,
the non-Cygwin CMD.EXE program produces a termination code which
is recognized in the Cygwin world.

Most likely it does that via ExitProcess.

It is odd if calling ExitProcess in a Cygwin process causes
a Cygwin parent not to similarly process the status, as seems
to be shown by Jay's test cases.

Cygwin supports non-POSIX programming; you can write GUI applications
using Win32 calls for instance.

(Now I agree that for exiting your process, even if it's a GUI
application using numerous win32 calls, you should probably do it the
Cygwin way, and use exit, or return from main. But still ...)



  reply	other threads:[~2022-01-13 17:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13  6:39 Jay K
2022-01-13 13:40 ` Eliot Moss
2022-01-13 17:07   ` Kaz Kylheku (Cygwin) [this message]
2022-01-13 17:19     ` Brian Inglis
2022-01-13 23:15       ` Jay K
2022-01-14  6:19         ` Brian Inglis
2022-01-26 14:23         ` Andrey Repin
2022-01-26 17:06           ` Jay K

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=72e0f0601676717a2702ff13beb45b80@mail.kylheku.com \
    --to=743-406-3965@kylheku.com \
    --cc=cygwin@sourceware.org \
    --cc=jayk123@hotmail.com \
    --cc=moss@cs.umass.edu \
    /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).