www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/01/13/12:19:52

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D06DE385840D
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=SystematicSw.ab.ca
Authentication-Results: sourceware.org;
spf=none smtp.mailfrom=systematicsw.ab.ca
X-Authority-Analysis: v=2.4 cv=IaOU5Ema c=1 sm=1 tr=0 ts=61e05f25
a=T+ovY1NZ+FAi/xYICV7Bgg==:117 a=T+ovY1NZ+FAi/xYICV7Bgg==:17
a=IkcTkHD0fZMA:10 a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10
Message-ID: <4f1b70a7-22e0-685b-ab00-9af895ed4e51@SystematicSw.ab.ca>
Date: Thu, 13 Jan 2022 10:19:32 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Subject: Re: ExitProcess does not work in Cygwin?
To: cygwin AT cygwin DOT com
References: <MWHPR1401MB1951896B7184CC9CC408CD07E6539 AT MWHPR1401MB1951 DOT namprd14 DOT prod DOT outlook DOT com>
<1f98eb84-e3d7-bf0d-875c-3d4818e41aef AT cs DOT umass DOT edu>
<72e0f0601676717a2702ff13beb45b80 AT mail DOT kylheku DOT com>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Organization: Systematic Software
In-Reply-To: <72e0f0601676717a2702ff13beb45b80@mail.kylheku.com>
X-CMAE-Envelope: MS4xfFpe+Fiyss7BGjgvkUpaeY/CAZAVyxfat+vUftMbtZCytSgi2PGGeoQFUu42bCNZW8ypxzbkIVlMmNa3RTRe5bp0KnWU7bMZmClJfEL1HIQTo2wKHIT+
DgA7Bnr8glPKqq/D4cwVADBKzz4mU7I8GizwaZtujqNJRG+4jNJW0p1nO+vX4yvfrXI68Rmw1pcOgeWMZpZ9U5Ms0oU2C5Zf3oC79/lNqlfdZEE2r/OZgH0d
X-Spam-Status: No, score=-1160.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL,
SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Cc: Jay K <jayk123 AT hotmail DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 20DHJqxc008190

On 2022-01-13 10:07, Kaz Kylheku (Cygwin) wrote:
> 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?

Just use POSIX exit(3)!

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

Cygwin installs at-exit handlers and it is likely that when these have 
finished, they return a Cygwin exit status if passed by the POSIX 
function, perhaps unless some error has occurred during at-exit handling.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

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

- Raw text -


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