Giter Site home page Giter Site logo

test_parenting's Introduction

test_parenting

Test program to explore effects of exec on parent/child relationships under cygwin

Fixed

Note: This problem has been fixed in version 3.1.2 of the cygwin package.

Running

To run this test program:

  • make parent_test
  • ./parent_test2.sh

What is going on:

parent_test.sh launches sleep 15 in the background, reports the parent and child PIDs and runs ps to show that the operating system is in agreement. Then it executes exec ./parent_test, which replaces the bash shell with the minimal test program to monitor the child processes.

parent_test2.sh launches parent_test.sh in the background, reports its PID, waits a bit to avoid confusion and then runs ps to show the geneology after the exec call.

How it should work:

On Ubuntu 16.04, I get the following:

Parent pid is 5031
Child pid is 5033
UID         PID   PPID  C STIME TTY          TIME CMD
nort       5031   5030  0 15:16 pts/19   00:00:00 /bin/bash ./parent_test.sh
nort       5033   5031  0 15:16 pts/19   00:00:00 sleep 15
nort       5034   5031  0 15:16 pts/19   00:00:00 ps -f
Parent PID is 5031
UID         PID   PPID  C STIME TTY          TIME CMD
nort       5031   5030  0 15:16 pts/19   00:00:00 ./parent_test
nort       5033   5031  0 15:16 pts/19   00:00:00 sleep 15
Process 5033 terminated: status 0000
No more children

As you can see, there are two reports from ps, followed by a report from parent_test that the child precess (5033) has terminated.

What happens under cygwin

$ uname -a
CYGWIN_NT-10.0 easwhlpt3425080 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
$ ./parent_test2.sh
Parent pid is 2386
Child pid is 2388
     UID     PID    PPID  TTY        STIME COMMAND
    nort    2389    2386 pty2     15:17:29 /usr/bin/ps
    nort    2390    2386 pty2     15:17:30 /usr/bin/bash
    nort    2388    2386 pty2     15:17:29 /usr/bin/sleep
    nort    2386    2385 pty2     15:17:29 /usr/bin/bash
No more children
Parent PID is 2386
     UID     PID    PPID  TTY        STIME COMMAND
    nort    2388    2386 pty2     15:17:29 /usr/bin/sleep
    nort    2386    2385 pty2     15:17:29 /home/nort/SW/test/parenting/parent_test

Here you can see that parent_test immediately reports "no more children" even though the subsequent ps output still shows the expected parent/child relationship. (Note that parent_test.c includes a delay after "No more children" before terminating, allowing it to stay around long enough to be observed.)

test_parenting's People

Contributors

nthallen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.