From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by sourceware.org (Postfix) with ESMTPS id 05A9A3858D35 for ; Fri, 31 Jul 2020 08:10:34 +0000 (GMT) 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@cygwin.com Received: from calimero.vinschen.de ([217.91.18.234]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MjSHa-1kTNLJ0jb0-00kzCQ for ; Fri, 31 Jul 2020 10:10:31 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 43F9AA80D7B; Fri, 31 Jul 2020 10:10:25 +0200 (CEST) Date: Fri, 31 Jul 2020 10:10:25 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Synchronization problem with posix_spawn Message-ID: <20200731081025.GB460314@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <864b3031-9fc8-beb3-ba7c-1ade4c31a288@cornell.edu> <20200730115913.GL4206@calimero.vinschen.de> <20200730171723.GA460314@calimero.vinschen.de> <86051625-646d-065a-8543-1c3086411d3d@cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86051625-646d-065a-8543-1c3086411d3d@cornell.edu> X-Provags-ID: V03:K1:aWaEFFeo1DeRElX35OfIUWpZraNLSOCwCB7Wu5v/ZYuJQBECFb2 wweBEXmqJ3h8ct0QZjjivakfZ3meKgodTRXhfAVgDi+hty0CrgL+uxHCL96zRE+1zsUSGJg OsTQjk3QUX+tu2AcOQpOK9MQL3fVuODdOhq+YzUv1HtrbmHwFxT9HZuixYtqnv1JtjtUrwF xtQzjgOfuFOVsHD7aMdYg== X-UI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z57LuAptQiG 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Jul 2020 08:10:38 -0000 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