delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/01/13/18:15:32

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 05403385840D
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=hotmail.com
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.com
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=WIdGZKwc5au3NRrAGVRpXwIUU0yfX7V2jFg84nWe8tM8fGU5QAWwrq8u9K+Ml2BEDxqR5oHcFuQDfWpZ3DsIFeK1P58L4bItCThvALCS5QxHxafVu5jo5zPz5nPorHKEFxVbqwd0/Vv7ZqAENTsFlNPRtaT1Yon65jszqELQWM4gy/NYxpWhHgqaEcNwZh7lgPjCyeKcIGEuufJ04GrbHHTbZue96M26jSUQmhR3MdfTggiqxc0JVRDyj/+aExTY1WylePHkicDQEDd37H1gOHVdFd1pQZvMEJ1lVNbTLNgYB26M1N9Rp275ohGFmeJ++dwDdZ+I1yaGzT3tMNjjpA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=pOXx4DWxiFZPZYNvyaLGjot86Laize7gsim2gdG5B5o=;
b=NaUtKk4uHqqgo4gHBYz6RzwR5SErPNbZvAHnZvrJEcNALodkv2hEltHjYBsnLGf/Psy3uQhEk5BgSlMJKoRysytSfFr6/z0J6nWuRNZDsyU3q7ZiiAj/lOoJ+vo+l/RQzPf87X9AvuhPpA29a6pZtbdXtABzh0bT+lQZBDuKtuTTjFLA8k0OoHPhlabe8mSfAJH9K6ohyapX57/AknrsRlxOByf979Z696OsMd7I6DS3qqFx/XKd1V3fIzurqsiHIgnBMtiNZ2v28D8bne7GKpiyrmaTV+3DHl4QyTY6mGic1pRV3dcVMyM5or67Jjshr7jENzpJEvbF58krVKDLWA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com;
s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=pOXx4DWxiFZPZYNvyaLGjot86Laize7gsim2gdG5B5o=;
b=Hjv/nuuPQZb1KwRa8OCmMItBwryKVMi0sZdx65OZ0JnKFZvhdhYIHFDaozu6nuGwz5DRLvFqGDRK2mdgb4gyaAGdmvUtKfyEc8GoPfm3MdfB0qQ3KkxwfPJbI+vOsmzgQ+eIOXksrGcjOx+3oZPS7GJpPa0TI/vHTi/KxGA5Rhog48Dk2SJ2/rwtwiy8OUm5A36JUE+n36x/NIxa+WgBb6SLcgNCavLo+uUAgpx7HUMXFeC0ayeK6iHVQzlfASblvLsVmc8a+ao7IrnMR6O7c7Qb6qTOH23HFUiXpbA58cBGLTT0Wg1mb5PcFhNyjlMSzIw6YNS/LkN/wbTVw8uBbQ==
From: Jay K <jayk123 AT hotmail DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: ExitProcess does not work in Cygwin?
Thread-Topic: ExitProcess does not work in Cygwin?
Thread-Index: AQHYCEfOC6OhOx+KnE+yn5cQgqAkb6xg9aWAgAA5+wCAAANFAIAAY1Yi
Date: Thu, 13 Jan 2022 23:15:11 +0000
Message-ID: <MWHPR1401MB1951C6A27882346C9E2234C2E6539@MWHPR1401MB1951.namprd14.prod.outlook.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>
<4f1b70a7-22e0-685b-ab00-9af895ed4e51 AT SystematicSw DOT ab DOT ca>
In-Reply-To: <4f1b70a7-22e0-685b-ab00-9af895ed4e51@SystematicSw.ab.ca>
Accept-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
suggested_attachment_session_id: 5194c890-df84-eb18-0843-7e5ea3de2683
x-tmn: [lnl11yaCuAl8hdZX+iJAo3cMTwTNbjbU8EMUaxczyluFGwdEcIU9gX78MjT6Ci6y]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 59f78dad-66e3-4e1f-0f7a-08d9d6ea8c66
x-ms-traffictypediagnostic: MWHPR1401MB2048:EE_
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: II0+Og4B3SpAlXvblxa0bCIUMR4CNW1/QOBnkOm/VH4jSZR3Ot5rHgK+va3/itVQ+RyfDRV/Rysk4EP2kOYL6cL+CEJ0DQEyjOQnjzH87cryYCoLBTUGlXuZJOKpa1E9fE5t/+gQIcXNRXu3PcWw6qfsN5IKki9RrUj3dom0F5eYMhPMCGxvnKBbCnA8Kpwj2E9NzSe2j/C7byLsC4LnTcxiWX0gQlBxzM9Ri1hSw+zjzna6jT72IncBk7zXWDL00lfCKe9KQWWqXT00zVu1XdZp97S77ZpyYQmyObk3rSLcO+tC7spT79BxObkH2YK4VLSxcXdLghUay0qFc7fXre6kxuyqvTR+gAAUFh37LTZn1QbxRsex4TZyp8BWo03X1qV+v/WYjKZa342n4Bt8BHj9cjgf8rfyj5McstuK5HLvplxllLOOZwS0GjkMiYfQnXeyz9IMleO6tzuLWLcdVC/0zmuNmd7EW9sqcDs5kJfS9P6QgmuAri5MramtusCQO4X65O3fknEnbeMHrGpScgzqXvjOoR3dzbrpOBVIIM+ayJGPICka3dS/iaXxjQ6MEw7svnGqQ+8kRarP6egnCw==
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-mess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Ym2r8jLIErDEai+GcRTyMRhsE3CU3w+fwJ4iQpP2O?=
=?iso-8859-1?Q?gd7qhyVc6bXXv/uudWZkcnHiTlPkcCEScdEjEn1Gg97uswv4PlbSnd6Imj?=
=?iso-8859-1?Q?wWN9kVGYQ9KSgA6K1xJt8bTVV8j5kxL3mXTNu3pW07wXrm6qJkOBfSq35d?=
=?iso-8859-1?Q?clqyF+pZpYh1i7C2if2jE1I2+lgCiel5HnMF94?=
MIME-Version: 1.0
X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-cd57b.templateTenant
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: MWHPR1401MB1951.namprd14.prod.outlook.com
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 59f78dad-66e3-4e1f-0f7a-08d9d6ea8c66
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jan 2022 23:15:11.4888 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1401MB2048
X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT,
FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,
SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
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-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>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

 > Just use POSIX exit(3)!


I did switch my code:

#ifdef __CYGWIN__
 exit(x);
#else
 ExitProcess(x);
#endif
.

I think the problem is actually in how "Cygwin bash"
aka Cygwin, computes the exit code in exec/spawn/system.

I.e. it recognizes it is running a Cygwin exe or a native
exe and does things differently.

I admit I didn't read or debug much.

In one run I was debugging I did seem to see a crash
in some DllMain(process detach), without symbols, and then I seemed to see
ExitProcess(1 or 2) become ExitProcess(0xXX00) and
then I started wondering if Cygwin somewhere is only
taking the lower 8 bits, since I know that is a thing in some code.

But I didn't dig into this further before trying the simple case,
which I don't think crashes and really does NtTerminateProcess(1).

 - Jay

________________________________
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Sent: Thursday, January 13, 2022 5:19 PM
To: cygwin AT cygwin DOT com <cygwin AT cygwin DOT com>
Cc: Jay K <jayk123 AT hotmail DOT com>
Subject: Re: ExitProcess does not work in Cygwin?

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