delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/07/31/04:11:21

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 979653851C22
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1596183040;
bh=bHxnboqx1saaQMhKNfPf1uxrTj3SHkQwRxnXmDn5N6g=;
h=Date:From:To:Subject:References:In-Reply-To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
Reply-To:From;
b=cH0sywlBrdhmRVHd59aDFTx4thXyEz01g7yZaKYmOzMfwpZmhE6rJjHL8c7Gdgo9F
BswdpPbe5KQZblFgP51LXGGx6yXYpcQNQYZPu3pIc3exN+eaN+0eePKfurfo0K303K
xg3KVmaNs2WCHL9WzovcEiQZ2Oxbi8kMy7NELKAU=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 05A9A3858D35
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=cygwin.com
Authentication-Results: sourceware.org;
spf=fail smtp.mailfrom=corinna-cygwin AT cygwin DOT com
Date: Fri, 31 Jul 2020 10:10:25 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Synchronization problem with posix_spawn
Message-ID: <20200731081025.GB460314@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <b1992e8b-d2e8-9c44-8f93-a270d5a879ed AT cornell DOT edu>
<864b3031-9fc8-beb3-ba7c-1ade4c31a288 AT cornell DOT edu>
<20200730115913 DOT GL4206 AT calimero DOT vinschen DOT de>
<20200730171723 DOT GA460314 AT calimero DOT vinschen DOT de>
<86051625-646d-065a-8543-1c3086411d3d AT cornell DOT edu>
MIME-Version: 1.0
In-Reply-To: <86051625-646d-065a-8543-1c3086411d3d@cornell.edu>
X-Provags-ID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XS+pNwhHGq0yqL9o5Xpvol0gKHb0pW
KhDfOxrwbr0YYTHiwdu9SNxKXIMreoeiZWYdOdGbyBpUao13lJcNXTAk6Na3MrbHNf4rBhYI3
q/NrODZ0AJhtlBWGxSu4M8qZqcwadhqYMaDRpsW7lJa+R5s4wWIoxFCee+DDsx7tHAv6yg329
K+SbWVu53XHVS2f1+3Dj47Y4QvFcZW4RewU/YumHOsj3GUxv1uJeds/dqj66NKz57LuAptQiG
iTPWkUnKGUB7GxOMRQq9Ai7AAcX+kvjHWQcOMJWdb0aIUrWJtlGyhcOna09gg06uLgeIpTurK
j9317/Z2D9HFqeAC4iN/cH7nNE3km2Q4qfubYEKup4YBXwwzcswFmv0kY9cpdMmDrdO+sxws4
7xQkSR/JLDendYrt4QFdMhVZdKADkU2wJX3PDgyShGThBcVsqGxnyvFGZeOIhhxxgXk2I=
X-Spam-Status: No, score=-99.5 required=5.0 tests=BAYES_00,
GOOD_FROM_CORINNA_CYGWIN, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS,
RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 06V8B8cg024534

On Jul 30 19:04, Ken Brown via Cygwin wrote:
> Hi Corinna,
> 
> On 7/30/2020 1:17 PM, Corinna Vinschen wrote:
> > Hi Ken,
> > 
> > On Jul 30 13:59, Corinna Vinschen wrote:
> > > On Jul 29 19:12, Ken Brown via Cygwin wrote:
> > > > On 7/29/2020 4:17 PM, Ken Brown via Cygwin wrote:
> > > > > posix_spawn(p) returns before the spawned process is fully up and
> > > > > running.  [...]
> > > > I just took a look at the source, and I see that posix_spawn was taken from
> > > > FreeBSD.  Does FreeBSD have the same problem?  Should applications just be
> > > > aware of this issue and insert a sleep after posix_spawn before sending
> > > > signals?
> > > 
> > > Actually, this is a Cygwin problem.  I just had a look into the
> > > newlib implementation myself, and it turns out that the code,
> > > in particular the do_posix_spawn() function, is BSD specific.  It
> > > relies on the BSD implementation of vfork(2).  Cygwin's vfork(2)
> > > on the other hand, is NOT following the historic idea of the
> > > BSD vfork(2), rather it's equivalent to fork(2).  This is
> > > POSIX compliant, but certainly the reliance of the BSD vfork
> > > behaviour makes do_posix_spawn() as it's implemented right now,
> > > not overly functional for Cygwin.
> > > 
> > > IOW, we need a Cygwin-specific do_posix_spawn() using fork(2)
> > > in conjunction with some synchronization the BSD function
> > > gets "for free" by using its specific vfork(2).
> > 
> > Below is a POC implementation for a Cygwin-specific do_posix_spawn().
> > If this does the trick (at least your testcase works in my testing),
> > then I'm planning to move the function over to the winsup/cygwin dir
> > so it can be streamlined further.
> > 
> > Can you give it a try?
> 
> It looks like something further is needed: 'wait' doesn't seem to recognize
> the spawned process.

Oh well.  I did a quick test with your new testcase (thanks for that!)
and it seems to be a bit more complicated than I anticipated yesterday.
The parent-child relationship between the processes is broken.  I have
to think a while about this problem, stay tuned.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
--
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