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:to:subject:date:message-id:references :in-reply-to:content-type:content-id:content-transfer-encoding :mime-version; q=dns; s=default; b=Mj1V6hIPngK5glxibPQEqz4gzPf6K vAbA1l4IFlfVcLMpcOZnlTbPOhRWMNn2fZQk6YhyGfOJey9lh959SR8hwdTdlOel +FvWBKWfGfw/SZrYcYkGZ2Y2RR5uENnT36NFAM5+LdKhy5W34mz4nNZV0jeoXyRu nd4M7N20yvZZmk= 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:to:subject:date:message-id:references :in-reply-to:content-type:content-id:content-transfer-encoding :mime-version; s=default; bh=67IKA8mVI52cgnMCJohP9JqPtEs=; b=XRO OVL6nrYMdOuExsGNlyOGOFTImsVqFO/9XkNHVDy2pYrq+ajztqnUau+A3hn5wzxi TWTeTY1qUML6i5/gzWdPC4KMgkSlvBwb8x48ebfgae3cW/UHLtdAnYidG+cmDGKV FhQYWbxgn4PODnxu69fgT5w3SDpQ6TC9MnJGj7K0= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=0340, 0.340, cygwin_nt100, 3.1.2 X-HELO: NAM11-CO1-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FTtZTBxkh5jbIR7upwQcVFMQxRmnsJ6s+3mVWFpW1hq8o6VANq/wWoslKtK4HHm+ITWQAL1F1fV+DVqLuWBrKnsX6G6UgMwWVR1C91bLYTefafjEc032/n9elXTHfGrCVM0hwFuLo1zl6nqfHF/R4EjgG/FneXogViv24dB2iVC5X1ILjgJSJNXaaOA+S2wV3T4QOy7puSmYnGigsw+P56G5W2Cc/A3Ka+e1U0Aex7H49gXfb1Tao9VNXJSbnorEHbnJmnJGqFaADSE7i3wTQgmrsyiqUOCatPtGaZDP+i7W7Ano9JZfBUNJ95VpYciSfk2fnLK+t8GlJpHeUDYTLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R11sgrdXMD+sb4cizCMnJdzCkRvqJvtW5kYiDYzOfko=; b=SJ5K1rQbpENHoQe+IZkgZEsWvHiLaJzu0Ywq/DqGdk6UKQSEH3DtKISzmZSWTZZz61fxOjvhWNoKIPSYwJthJ8ftJQnBqUY7Zvpy2vcmwBU0iuGdFhL+78PSxyl6YnzliFi8dfNJwjqcOodt2oq4GqRUP7DIUaJlaRMWPSpvOqxCzFCWf6e+6NP0jx8hHYsMSJ/iTCdqyVtqIL+7VGthvGwZtQGe9yOftVceX01V3sOqnii2+3YQSHIvjpBKIZBK3QQ9wejfnxzz/v1BaaXLerCuvKHkeU3dI5UwsmKCnTHDVt4JrWLP+cgCvagdzKV8maWfTD2Qa/xW6Am+kt807g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R11sgrdXMD+sb4cizCMnJdzCkRvqJvtW5kYiDYzOfko=; b=YYZohm5uxy5sjvvdDJqD4+r+FaUfDJaZ4RETYhrqvJIyH4dnWtkJh+/Ic50FVLsh1sdXQJug5GTiSbGF+NeTEt18Ij8Wzl52W+CLRQu3vqM9PgAW1KfuvErhhMLIZx8gQttu1ChQO/vjAYC/NgosVXG36jFf2oOJHe6fsdrO9FA= From: Ken Brown To: "cygwin AT cygwin DOT com" Subject: Re: Cygwin parenting issue Date: Wed, 1 Jan 2020 23:24:47 +0000 Message-ID: References: <7cb7cef9-0e4b-8e9d-0c14-ffe3e9e79a13 AT huarp DOT harvard DOT edu> In-Reply-To: <7cb7cef9-0e4b-8e9d-0c14-ffe3e9e79a13@huarp.harvard.edu> user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=kbrown AT cornell DOT edu; x-ms-oob-tlc-oobclassifiers: OLM:8882; received-spf: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-ID: <437C7AE1E5F7EE4E9EB005FBC18B8EFE AT namprd04 DOT prod DOT outlook DOT com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: IpRa1m7GQ+x9M2rqCsUOKzN9mxjQxvL/agDEiG0HDyERpL8V28JoEMANKtZ3GYkWkTAMrt395les4fNZr9Sw9Q== X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 001NPR5j027807 On 1/1/2020 4:01 PM, 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. > > I have a minimal test setup at https://github.com/nthallen/test_parenting, along > with examples showing how it works under Linux and Cygwin. This looks like the issue that was reported here: https://cygwin.com/ml/cygwin/2019-09/msg00263.html It's been fixed. Try updating the cygwin package. $ uname -a CYGWIN_NT-10.0 moufang2 3.1.2(0.340/5/3) 2019-12-29 17:28 x86_64 Cygwin $ ./parent_test2.sh Parent pid is 24159 Child pid is 24161 UID PID PPID TTY STIME COMMAND kbrown 24159 24158 pty4 18:07:48 /usr/bin/bash kbrown 24162 24159 pty4 18:07:48 /usr/bin/ps kbrown 24161 24159 pty4 18:07:48 /usr/bin/sleep Parent PID is 24159 UID PID PPID TTY STIME COMMAND kbrown 24159 24158 pty4 18:07:48 /tmp/test_parenting/parent_test kbrown 24161 24159 pty4 18:07:48 /usr/bin/sleep Process 24161 terminated: status 0000 No more children Ken -- 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