2

この記事の最後の例は、意図したとおりに機能しません。これはコードです:

私の環境は Fedora 24 で、これは私が受け取るべき出力です:

  • # ./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
    

ただし、これは私が受け取る出力です:

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

あたかもorphanの子が何もせず、再親化されていないかのようです。ただし、のシェルorphan経由で ( なしで) 実行すると、期待どおりに動作します。simple_initns_run

4

0 に答える 0