From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by sourceware.org (Postfix) with ESMTPS id 754423858D35 for ; Mon, 3 Aug 2020 13:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 754423858D35 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 1M8hMn-1k7HFV00TB-004mbn for ; Mon, 03 Aug 2020 15:22:36 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 7CAC5A807C3; Mon, 3 Aug 2020 15:22:35 +0200 (CEST) Date: Mon, 3 Aug 2020 15:22:35 +0200 From: Corinna Vinschen To: cygwin-developers@cygwin.com Subject: Re: Synchronization problem with posix_spawn Message-ID: <20200803132235.GO460314@calimero.vinschen.de> Reply-To: cygwin-developers@cygwin.com Mail-Followup-To: cygwin-developers@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> <20200731081025.GB460314@calimero.vinschen.de> <20200802115522.GC460314@calimero.vinschen.de> <20200802145054.GE460314@calimero.vinschen.de> <70e56891-fcb0-ba2b-b6de-c29ff1dc970f@cornell.edu> <20200803112239.GM460314@calimero.vinschen.de> <3afe1757-5060-c87c-5772-b1a97f5d6381@cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3afe1757-5060-c87c-5772-b1a97f5d6381@cornell.edu> X-Provags-ID: V03:K1:TT6la3Y8RGqWu7eKKjAxIKcZUHSy/TTNgD8Y9lDrN4syw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wFolxUsqcfUocIf9h6C2l8FmJtC6jyHQBXf4+x tsYq/4JzAdgtQknlaSYg== X-Spam-Status: No, score=-99.9 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, 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-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2020 13:22:39 -0000 On Aug 3 09:10, Ken Brown via Cygwin-developers wrote: > On 8/3/2020 7:22 AM, Corinna Vinschen wrote: > > On Aug 2 12:21, Ken Brown via Cygwin-developers wrote: > > > On 8/2/2020 10:50 AM, Corinna Vinschen wrote: > > > > On Aug 2 13:55, Corinna Vinschen wrote: > > > > > [Moving this discussion to cygwin-developers] > > > > > On Jul 31 10:10, Corinna Vinschen wrote: > > > > > > On Jul 30 19:04, Ken Brown via Cygwin wrote: > > > > > > > On 7/30/2020 1:17 PM, Corinna Vinschen wrote: > > > > > > > > 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. > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > Actually, this is a Cygwin problem. > > > > > > > > > [...] > > > > > > > > > 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(). > > > > > > > > [...] > > > > > > > > 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 attached another patch. This one is designed from the ground up and > > > > > I *think* it works as desired. I added lots of comments so the idea > > > > > behind this patch should be clear enough. > > > > > > > > > > Please give it a try. > > > > > > > > Version 2 of the patch attached. It occured to me belatedly, that > > > > parent and child have to be synchronized prior to calling WFMO in > > > > the parent. Otherwise OpenProcess in __posix_spawn_sem_wait_and_close > > > > may end up opening the exec'ed process rather than the forked child. > > > > > > LGTM, and passes all the tests I could throw at it. > > > > > > FYI, I noticed the posix_spawn problem because I've been regularly testing > > > my FIFO code by running the test suite from the "casual" project > > > (https://bitbucket.org/casualcore/). That project uses FIFOs extensively, > > > and it also uses posix_spawn. I only realized a few days ago that some of > > > the test failures I had been seeing had nothing to do with FIFOs but rather > > > stemmed from the posix_spawn issue that I reported. Those tests now all > > > pass with your patch. > > > > Great, I pushed version 3 of the patch (with an additional minor fix). > > Can you check this version again, too? > > All posix_spawn tests still pass. > > Ken \o/ Corinna