X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F98D3858409
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1709534734;
	bh=ehk8/xCMXPBDT/83kOIKPjETl0SJfpCiKoTybOP+qzU=;
	h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=ZFU/hVwZ3SXqmVt4pv1HF9ye75Y7od6CZEY61Nc/mDDsG5Xy2wrx7mMv84dT9Guct
	 IhM/eMDsbImKBI/ArxR/sW+bsNUSURvy7wUc+jOtaGL7WXzL0Xz4UWxBbKjPR/ZCNd
	 YNzOYTlCLXpbirrdd6fD+MQsm5UfUk4OquTkF8bc=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C5FE3858D28
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9C5FE3858D28
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709534714; cv=none;
 b=bQxgyufC1VsEFzxMhcBbTcBgjUiIu7ABdW2FQwSE/axlgfVa0BgDcoWmKUhKEuMVIeyhT7fqC84K8QUI7ZXq44gQI1FRonUscQ9If/pE5Le8VmWvkbbFfXi4FTEeZFKSeLWyNOBOUTTbswkF5U5hMW0cfK32kb6V3g7HjA6tHD4=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1709534714; c=relaxed/simple;
 bh=FrhRPL99Tjaso0+eTm09CD27zKjjDTjnhY0L90hwJs4=;
 h=Message-ID:Date:MIME-Version:Subject:To:From;
 b=nADRmgnLP6Krm83lFfBN8lpB8Lx2zVYKQ/Q/p2n1TOYNkBirx414blhHHXc07C4IreI7II/h86aNwnl7WLD+/sFNDiaD2NJVsgZB3KtQSF+pS9Zq1xHG8q0qdtnTpQqHYfW/b8X5uG2jCDsr+2E5WyLFaUxdUPFYnAT1jnGiS0A=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <da003a14-a7ea-46d8-8ded-0f4e49290704@maxrnd.com>
Date: Sun, 3 Mar 2024 22:45:14 -0800
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Native posix_spawn() in Cygwin?
To: cygwin@cygwin.com
References: <CAAvCNcCSaRBKYwd8-bU_rRh+m9LajyAVSHi3vH_3iaxwg1GE-Q@mail.gmail.com>
 <00ca6f45-aef6-4d0c-9440-8a00b2de487a@SystematicSW.ab.ca>
 <CAAvCNcDeYwhpq4Q9ftRgq3oErZNiS=x7DaLr-Lt6gAzG-npGfA@mail.gmail.com>
 <Zd2ChRq46MUMv0rU@xps13>
 <CAAvCNcBTRkJuD52dZsPePAG_yK_cBc=Ps4QPeG1BBXdZp5OYdg@mail.gmail.com>
Content-Language: en-US
In-Reply-To: <CAAvCNcBTRkJuD52dZsPePAG_yK_cBc=Ps4QPeG1BBXdZp5OYdg@mail.gmail.com>
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
 SPF_HELO_NONE, SPF_PASS, TXREP,
 T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Mark Geisert via Cygwin <cygwin@cygwin.com>
Reply-To: Mark Geisert <mark@maxrnd.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On 3/3/2024 7:27 PM, Dan Shelton via Cygwin wrote:
> On Tue, 27 Feb 2024 at 07:34, <gs-cygwin.com@gluelogic.com> wrote:
>>
>> On Tue, Feb 27, 2024 at 06:54:42AM +0100, Dan Shelton via Cygwin wrote:
>>> On Tue, 27 Feb 2024 at 06:47, Brian Inglis via Cygwin <cygwin@cygwin.com> wrote:
>>>>
>>>> On 2024-02-26 20:23, Dan Shelton via Cygwin wrote:
>>>>> Does Cygwin implement a native, i.e. without form(),exec(), implementation of posix_spawn()?
>>>>
>>>> Check the API compatibility docs online:
>>>>
>>>>          https://cygwin.com/cygwin-api/compatibility.html#std-susv4
>>>>
>>>> or optional locally installed package cygwin-doc:
>>>>
>>>>          /usr/share/doc/cygwin-doc/html/cygwin-api/compatibility.html#std-susv4
>>>
>>> That document does not answer my question.
>>>
>>> I know posix_spawn() is there. But the question is: Does it use just
>>> Cygwin fork(),exec(), or the native Win32 spawn() api?
>>>
>>> Dan
>>> --
>>> Dan Shelton - Cluster Specialist Win/Lin/Bsd
>>
>> If you were going to make a small effort to answer the question
>> yourself, you could use strace, you could step through a debugger, or
>> you could check the source code.  Have you tried any of these?  What did
>> you find?  If you are unable to take any of those steps, why does
>> posix_spawn() matter to you?
> 
> strace does not help, as I need the Win32 calls BELOW posix_spawn(),
> to see the implementation details.

Check the source code, then. It's at:
     https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/fork.cc

Look at line 587; there's the static function dofork(). Look at the
thirty or so lines above that; there's both fork() and 
__posix_spawn_fork() calling dofork(). So both those user-level
functions call into the exact same internals. (BTW __posix_spawn_fork() 
is called from posix_spawn(); the latter is in newlib and not Cygwin.)

You can even see the reason it's done this way by reading the comment.

..mark

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