DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 456NAlbN902066
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=FMj9LZLg
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 424ED38E0447
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1717715445;
	bh=AMJUXw6dfxDzWhIXPpRN/gltNMnpLkwotkI5XlKhYkk=;
	h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=FMj9LZLgmDu0NqJ19/VjSZ2nx6kPSUZ7vv3SbLDVHuMQln1J705HUbN/jpmc+JfAt
	 PY8FGSkRXhF0G8ELFzdtbj0akQdIes3asGokaIqz64vyAeyP4373LWr3B0Wwig7TFF
	 y4of3sH0mFyZthaBPd3ySAnyOngJISilfB1T1Mds=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85B0D38E0447
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 85B0D38E0447
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717715419; cv=none;
 b=TWzBbbPv6IL/if7gWvyrALUqukOzueRpNdM4eb20kqTMoG3xCVugSqo9LUrMVYgSFqrI6pF95o6zh5BdiPoY3XkE+pkk8iRUrTR0oGN4XKPKhG/m4zCyxhW2OGbV00GOJC84H8qk7msOWnaxcdc3QkwPWczL6rwZAPtmc72Pjk8=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1717715419; c=relaxed/simple;
 bh=iXEklivP2yhzrreqNFfnMTUphG71jU4ynC7ljHiwbrU=;
 h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
 b=sTKsN516Z1XFtFfGGEhAfkJbY3XGVvJmZOQ4brf61A7vbDvFlf3alkx9COz3HMtcJD0+0A15yHQ/VZimEoujIEFdsIJsgzZE7ealwwAqEwmRmTEthFHuW5nUMKw03xf2FHL0LyQ/haQPj7f04I8+efhwvnWVt1e2/QpbKl28iwQ=
ARC-Authentication-Results: i=1; server2.sourceware.org
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1717715415; x=1718320215;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=Thx8Dqg4aCWq8ZKnc6MzaAi6RduEWHbq4hZn9AS/+qg=;
 b=kva9ahy32W1XVNs2ARJmgOeQk4/a4BIvAw6G4CxCFEBAxboJcQKDIVfrou3D2sr2LL
 ICMmPRmCnzOsYJQpWSjGL7TNemoBgaRKfcTc85d1MVRDVQpFxyk7Rpvj4K19pjTvfN9W
 BiHH6eBw0LZHeJIJDUr7A6VdhgzTCKhwDee7iNkgwByT8Alc5zkImvBZFzGix2P1uE1j
 ZmcJWW3Xvoj82c4FCEhpLdix0cceinsVKK1AJKDM/6QfoNOZKcY/B32/V4h7A5WFHBp0
 VVbTBrOGzb/JrkMwcQ6zApkXCWdvFibnwwrsTzeE+XQDYhhB5eFo5RNxExsKS+bFvBPq
 kpyQ==
X-Gm-Message-State: AOJu0YxcMR5F2xho9eIRnLr06kYKS18M9ui2QfR3EOx1ufLU+dfQA1yb
 3JCJwrT/NmYZ3VOCOzSNqk5ef/kD4MSiCew0lV+f/zuLppfm1L+tYUFiLtlzakzT/sSkbFFh+on
 NkSWjk9w+oUhuQ+Pmrn0C8/8Orn7Nl/Fe
X-Google-Smtp-Source: AGHT+IHIWkMG6kND/y61qM219CrmDzFJJ+DLj9F6HwSuV1b0pmEaEPZUWGFCsPN8+tPp0PSMEhHTYcq+TqlVVwJuems=
X-Received: by 2002:a05:6512:441:b0:521:532d:eb38 with SMTP id
 2adb3069b0e04-52bb9fd2d87mr583671e87.63.1717715414530; Thu, 06 Jun 2024
 16:10:14 -0700 (PDT)
MIME-Version: 1.0
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>
 <da003a14-a7ea-46d8-8ded-0f4e49290704@maxrnd.com>
 <CAAvCNcC6232r+r-a4fme_POrWis_e9yEgMXrLk00E1ptRbS7UA@mail.gmail.com>
 <4ab591dc-6586-4879-94b1-a3c087af1d4f@maxrnd.com>
In-Reply-To: <4ab591dc-6586-4879-94b1-a3c087af1d4f@maxrnd.com>
Date: Fri, 7 Jun 2024 01:09:48 +0200
Message-ID: <CAAvCNcDbodKmjKZESBFbMxES7Ddj8ZyQJKJWHAKgvomVi81XyQ@mail.gmail.com>
Subject: Re: Native posix_spawn() in Cygwin?
To: cygwin@cygwin.com
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
 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
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
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: Dan Shelton via Cygwin <cygwin@cygwin.com>
Reply-To: Dan Shelton <dan.f.shelton@gmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On Wed, 6 Mar 2024 at 01:08, Mark Geisert via Cygwin <cygwin@cygwin.com> wrote:
>
> On 3/5/2024 2:42 PM, Dan Shelton via Cygwin wrote:
> > On Mon, 4 Mar 2024 at 07:45, Mark Geisert via Cygwin <cygwin@cygwin.com> wrote:
> >>
> >> On 3/3/2024 7:27 PM, Dan Shelton via Cygwin wrote:
> [...]
> >>> 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.
> >
> > Yes, but it is as I feared, Cygwin posix_spawn() does not use Win32
> > spawn() at all, and instead uses a rather inefficient vfork()
> > solution.
>
> Cygwin's vfork() is just a wrapper around fork(), so yes. But anyway...
>
> > posix_spawn() was added to POSIX so a Win32 implementation can use Win32 spawn()
>
> ...now I see what you're getting at:
>
> If posix_spawn() is intended to launch truly unrelated processes, with
> minimal or no coordination with the launching process, why can't it just
> use Windows' CreateProcess? I assume here that's what Win32 spawn() does.
>

I'm not sure, but I think this would benefit Cygwin greatly to
implement a native posix_spawn(). It should be faster and scale
better. Also the only stuff which do really need fork() are
bash/dash/ksh, and maybe daemon stuff like sshd.

Re CreateProcess: Maybe CreateProcess() breaks access token or newgrp support?

Does Cygwin do bounties (paid bug fixes), or Google Summer Of Code?

Dan
-- 
Dan Shelton - Cluster Specialist Win/Lin/Bsd

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