delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/01/01/17:17:58

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:from:subject:to:references:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=KjyKK5h3gfke4AI6
+RQPejwymHIXsxp//FXwCsFlzgw8b4IZXa22BYCEkhjOCZ50Zged9LSryXvxoTKg
Z3MHRVv+C+hOaBnIadEnOsVRZwroRRD5EKByzQpxqldhyeELsyGpXLoMXOfX9TCv
kwLjBazrKRj/BFre6xg4B+wGwz0=
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:from:subject:to:references:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=74qw0HMHrJk9O0dzmrLhBI
7Evz0=; b=A9JY1hqw6stJawaGybCJ3WD0xz1ybscw5k1QpWVdKZWj+7pdRTKIet
aA0IZGZPWH7hJSIqNiOEyt9y1svOz+AiFm3DIhVZ9gPDB/4GEs/YIO+0mwOpUoXX
Kzf73o5O0m7/g6Q47tJVvZhoCjT0PNW6RrNtT5sluok9IHTwkYVes=
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=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=Allen, allen, expert, HContent-Transfer-Encoding:8bit
X-HELO: mail-pj1-f67.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=Tm0tLoZHfbro8+1JxfkmkyDo1HwcBTcsoR86QqwnQeI=; b=nftaJw+oSOnsEFKMo52IzoBlHPRyXYp5/7wUX+BQ0ML8pb4kfngb+SXMP/GjzjjkGB WVOB2JBn/HUEnyBvEHX4MWy98g+UVUE+mDkrox2nLBF1dx1wIc4wupYPsGr+KSMmsLzh 3wJ6fIQzI4ue+alUOgHV0KFWX62KRa42QdvKOijN8ZlNzU7zrSbzx0tEVtyDed3C0esN suXSuecqtOGdULwxbCl+s87k1UYfnf1fckYV0AxLeIBL274hLyWe++a+uCxjiZoBJoe5 EXB9W9PEKV3rNraom2TKyTOO0IGwfXTKQYNVHAJH41D7Gb7nslCOpql8fQi28f2XeQ3Y AzRg==
From: David Finnie <david DOT finnie68 AT gmail DOT com>
Subject: Re: Cygwin parenting issue
To: cygwin AT cygwin DOT com
References: <7cb7cef9-0e4b-8e9d-0c14-ffe3e9e79a13 AT huarp DOT harvard DOT edu>
Message-ID: <6083329d-bc0b-fc68-9a43-70797e06edb1@gmail.com>
Date: Thu, 2 Jan 2020 09:16:59 +1100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1
MIME-Version: 1.0
In-Reply-To: <7cb7cef9-0e4b-8e9d-0c14-ffe3e9e79a13@huarp.harvard.edu>
X-IsSubscribed: yes
Note-from-DJ: This may be spam

Hi Norton,

I've only just grabbed the cygwin source code very recently out of 
desperation to try to solve a different problem that I'm experiencing, 
so I'm definitely no expert.

However, in the source is a file called "how-spawn-works.txt", which 
does have a disclaimer at the top:

(THIS DESCRIPTION IS OUT-OF-DATE)

However, what it does say is:

* if the mode is _P_OVERLAY (we are doing an exec)
wait for the child to
a) if it's a cygwin process, signal us via an event.
b) if it's a win32 process, exit.
c) exit.

And, from what I can tell, that's what the new code still does. i.e. it 
is a new process being created, because the Windows API doesn't have an 
equivalent to the POSIX exec() type functionality. So... your executed 
programme (i.e. parent) is not simply replacing the bash executable 
within the same Windows process - it is actually inside a child process.

Having said that, given that cygwin manages its own pids, I think it 
should be able to simulate the waitpid() functionality within the 
concept of an exec.

For example, I did notice this bit of code:

       cygpid = (mode != _P_OVERLAY) ? create_cygwin_pid () : myself->pid;

So clearly it is trying to preserve the same pid. I'd have to dig much 
deeper into the code to try to work out why waitpid() is not doing what 
you want, but perhaps there is someone else who already has that knowledge ?

Dave

On 2/01/2020 08:01, Norton Allen wrote:
> I have a project that involves starting a number of programs in the 
> background and then monitoring and reporting when they terminate. My 
> approach has been to write a small application called 'parent' that 
> loops on waitpid() until there are no more children. I invoke it in a 
> script like:
>
> #! /bin/bash
> program1 &
> program2 &
> program3 &
> exec parent
>
> This of course works under Linux, but under Cygwin, although 'ps' 
> documents the parent/child relationship, waitpid() immediately returns 
> ECHILD, indicating there are no child processes. If I use the shell's 
> waitpid, that works alright, so I am wondering whether the problem is 
> a casualty of the exec.
>

--
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