From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.187]) by sourceware.org (Postfix) with ESMTPS id 9CF80384402D for ; Thu, 30 Jul 2020 11:59:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CF80384402D 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 (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M5wgF-1k7Qjp0JFj-007Sci for ; Thu, 30 Jul 2020 13:59:14 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 994E8A80D72; Thu, 30 Jul 2020 13:59:13 +0200 (CEST) Date: Thu, 30 Jul 2020 13:59:13 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Synchronization problem with posix_spawn Message-ID: <20200730115913.GL4206@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <864b3031-9fc8-beb3-ba7c-1ade4c31a288@cornell.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <864b3031-9fc8-beb3-ba7c-1ade4c31a288@cornell.edu> X-Provags-ID: V03:K1:d81XxkfzTeZd/Y0g5CTESvSLdL9AeOKl5B1FN1I7bh3fE9alPeM 55DTRWVJqx6p7RqHBaFTRbQq3SongVdH1UFspVsyXtzNkNInxAc77XoGCthS9KM1G08ZYtp NH9Ytpu+GmJCRGYNJsRv51m35gY2AD/TM9PSXxLmRj7Wx73VWTIZqYwG0b6zA8j2l+wbWQo JF9TFUW+KbCVS7z0AKiTw== X-UI-Out-Filterresults: notjunk:1;V03:K0:f35PkK+c6Co=:Q8mczEVjZrPrBDHzeqazFV 31w1V3XuWBeEz6Bam9XLI7tzC2fq+zNTv27xviK03u5cCh9mjgEc79wOgkxybwmYUeqvlqf4+ eiYWZwKNhybap0r6hYBJzP9kXL2prokA8+xuBfdc41WceofEWwNtCgTxCjs84dZd5kBZn/uhv 89cLW4Q0Z3Fd/zNxe3mlDEG4lLSlVXz9SzYafYCh1V53oK+YPZoKyeiyUK3955fpGG1Eg7gcK dM8rtmvpfyrbrxQ/qrbW4kQB/2qkOIrHJhSSOwEKcrnqFoyFhRXlH0BIxh/zFjbnxvh9eu9d2 GHOVgzXWyzFIhFmcUqAZdYUGxu+SNPLUboR+oBCDbt8gWxm9PR1mWj6eZLbsqtK1JiiOfyfOI QxdEM3Q5zeqb884WMG/ZZCphu3Oop8gZEQ1gSM8O7q9JoEK7B+DAB7n/7gMG/l29sDKneBpII FeThd+wJ9FbGLDKWC4gun9rxS7k0fPzKIF4z9GMXXpHvlUCyth927jN+hR0h90OSxSxraP+hx /GKYIfvH2e+FBprOnvj7cxcwcmsptERY6dkZ6MjCwNHrx75dNcxsnaSFQGN2nKpvHgl3xG+dd N7yn0xRRw9U8QzCn6RhYe5W5ax1NGqqM1ft+2akaQb3DmbE+3uPqkT58T+1aPBppf6KpwHjtu b1QXwWmVGB8C7+B77d/Y/5ad5TZX+aUjWWd0wvgrHEU2Ef3KESnqlNdiFPcJ3+iQc0dAeuQCF kMHsE5syCIqmcqbV3hzYBrPEQ3YuZjPlITG1UzZLl7UG6j9pv8rVDmBkrIHVIKhq/p75h9wE6 h/tJkhBOusOBlHZsQwuBxdyxJPsbTJk3OVnds4exUXwzn9am8tHHVMpZQf+yEq37GlCCL5gQQ GyAIYEGoNwcdEaoTyTZA== X-Spam-Status: No, score=-99.7 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@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: Thu, 30 Jul 2020 11:59:17 -0000 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). Corinna -- Corinna Vinschen Cygwin Maintainer