public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin-developers@cygwin.com
Subject: Re: Synchronization problem with posix_spawn
Date: Mon, 3 Aug 2020 09:10:03 -0400	[thread overview]
Message-ID: <3afe1757-5060-c87c-5772-b1a97f5d6381@cornell.edu> (raw)
In-Reply-To: <20200803112239.GM460314@calimero.vinschen.de>

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


  reply	other threads:[~2020-08-03 13:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <b1992e8b-d2e8-9c44-8f93-a270d5a879ed@cornell.edu>
     [not found] ` <864b3031-9fc8-beb3-ba7c-1ade4c31a288@cornell.edu>
     [not found]   ` <20200730115913.GL4206@calimero.vinschen.de>
     [not found]     ` <20200730171723.GA460314@calimero.vinschen.de>
     [not found]       ` <86051625-646d-065a-8543-1c3086411d3d@cornell.edu>
     [not found]         ` <20200731081025.GB460314@calimero.vinschen.de>
2020-08-02 11:55           ` Corinna Vinschen
2020-08-02 14:50             ` Corinna Vinschen
2020-08-02 15:32               ` Corinna Vinschen
2020-08-02 16:21               ` Ken Brown
2020-08-03 11:22                 ` Corinna Vinschen
2020-08-03 13:10                   ` Ken Brown [this message]
2020-08-03 13:22                     ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3afe1757-5060-c87c-5772-b1a97f5d6381@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin-developers@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).