Cygwin parenting issue
Ken Brown
kbrown@cornell.edu
Wed Jan 1 23:24:00 GMT 2020
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
More information about the Cygwin
mailing list