delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/02/08/07:56:28

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=nyabaEai3dhlTSuB
Rl8PtN0mMhGDuzPB/6jJngmPMcFyv4KJRX2q0ix/dSST6rnf+8308YB8P9UjEEWq
wuCnEehXOn2I7BuKHgwx1SHQYtOfk2WxoX1/UroZoQphXgBsFiC2lzuOOinKPA5Q
mUJbPt7wTefl4KKC4/IHRqV9Zuk=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=b9LRUFUol/sixYqM9qo7uS
zT2tQ=; b=T3MthvFpmLlIc63dDLsinBhQ82fbx8RI3tKEiCDTn9TzejCDSBdK68
yemqbbUs15URGZItJW+W9Y4PdSajEQMyeOeKwB9PqBf9jm7VZCVrZzc25D7MPpM4
Yq4WpEOLKmS0+JhoJg9k/DecbiVZ1A6vCslNVHBzeu5qMQO0jLpeo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=worker, Hx-languages-length:1942, informed
X-HELO: atfriesa01.ssi-schaefer.com
Subject: Re: [ANNOUNCEMENT] TEST: Cygwin 3.0.0-0.7
To: cygwin AT cygwin DOT com
References: <announce DOT 20190205151855 DOT GD16130 AT calimero DOT vinschen DOT de> <02da4eeb-fcce-b1bc-e6eb-68ff3ec0cf74 AT ssi-schaefer DOT com> <20190207182735 DOT GG13951 AT calimero DOT vinschen DOT de> <8a2f041f-f8f7-6e17-5d97-5a168440009b AT ssi-schaefer DOT com> <20190208113158 DOT GH13951 AT calimero DOT vinschen DOT de> <17e339bb-2115-bf22-7291-04215aab3150 AT ssi-schaefer DOT com> <20190208122126 DOT GM13951 AT calimero DOT vinschen DOT de> <20190208122338 DOT GN13951 AT calimero DOT vinschen DOT de>
From: Michael Haubenwallner <michael DOT haubenwallner AT ssi-schaefer DOT com>
Message-ID: <b07e6ba2-0ce0-4662-7a02-bda6ce3b0108@ssi-schaefer.com>
Date: Fri, 8 Feb 2019 13:52:12 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0
MIME-Version: 1.0
In-Reply-To: <20190208122338.GN13951@calimero.vinschen.de>


On 2/8/19 1:23 PM, Corinna Vinschen wrote:
> On Feb  8 13:21, Corinna Vinschen wrote:
>> On Feb  8 12:51, Michael Haubenwallner wrote:
>>>
>>> For now it seems like there's an inconsistency with PIDs:
>>> A first process PID 100, receives PID 101 from spawn(),
>>> but in the new process getpid() returns 102:
>>>
>>> $ ./dospawn /bin/bash -c 'echo $$'
>>> 12625
>>> waitpid: pid 12624 status 0x0
>>
>> Oh, hmm.  If you call spawnve, rather than execve, a new child pid
>> is generated in spawnve, rather than just keeping the callers pid.
>>
>> However, apparently the child invents its own pid in pinfo::thisproc
>> after being spawned.  But actually this should only occur for forked
>> processes aore processes started from non-Cygwin parents.
> 
> Does that help, by any chance:
> 
> diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
> index 78506d43de29..0b274287d9f6 100644
> --- a/winsup/cygwin/dcrt0.cc
> +++ b/winsup/cygwin/dcrt0.cc
> @@ -656,7 +656,7 @@ child_info_spawn::handle_spawn ()
>        !DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo,
>  			GetCurrentProcess (), &h, 0,
>  			FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
> -    h = NULL;
> +    h = INVALID_HANDLE_VALUE;
>  
>    /* Setup our write end of the process pipe.  Clear the one in the structure.
>       The destructor should never be called for this but, it can't hurt to be
> diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
> index 445bd35b224e..d10c4fc4580c 100644
> --- a/winsup/cygwin/pinfo.cc
> +++ b/winsup/cygwin/pinfo.cc
> @@ -62,6 +62,8 @@ pinfo::thisproc (HANDLE h)
>        cygheap->pid = create_cygwin_pid ();
>        flags |= PID_NEW;
>      }
> +  else if (h == INVALID_HANDLE_VALUE)
> +    h = NULL;

No, because cygheap->pid still is the parent's pid here, not the new child's one.

How should the child be informed at all about the new cygpid value generated in
parent's child_info_spawn::worker() ?

/haubi/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019