Failing example with LWN's "Namespaces in operation, part 4: more on PID namespaces"

64 views Asked by At

The final example from this article fails to work as intended. This is the code:

My environment is Fedora 24, and this is the output I should receive:

  • # ./ns_child_exec -p ./simple_init -v
        init: my PID is 1
    init$
        init: SIGCHLD handler: PID 3 terminated
    
  • # ps -C sleep -C simple_init
      PID TTY          TIME CMD
     9147 pts/8    00:00:00 simple_init
    # ./ns_run -f -n /proc/9147/ns/pid ./orphan
    Parent (PID=2) created child with PID 3
    Parent (PID=2; PPID=0) terminating
    # 
    Child  (PID=3) now an orphan (parent PID=1)
    Child  (PID=3) terminating
    

However, this is the output I receive:

  • # sudo ./ns_child_exec -p ./simple_init -v
        init: my PID is 1
    init$ 
    
  • # sudo ps -C sleep -C simple_init
      PID TTY          TIME CMD
     2665 pts/2    00:00:00 simple_init
    # sudo ./ns_run -f -n /proc/2665/ns/pid ./orphan
    Parent (PID=2) created child with PID 3
    Parent (PID=2; PPID=0) terminating
    # sudo ./ns_run -f -n /proc/2665/ns/pid ./orphan
    Parent (PID=4) created child with PID 5
    Parent (PID=4; PPID=0) terminating
    # sudo ./ns_run -f -n /proc/2665/ns/pid ./orphan
    Parent (PID=6) created child with PID 7
    Parent (PID=6; PPID=0) terminating
    # sudo ./ns_run -f -n /proc/2665/ns/pid ./orphan
    Parent (PID=8) created child with PID 9
    Parent (PID=8; PPID=0) terminating
    

It's as if orphan's child does nothing, and is never re-parented. However, running orphan via simple_init's shell (without ns_run) works as expected.

0

There are 0 answers