ravinet/mahimahi — pull request #11 by anirudhSK (2013-09-01 14:59:30+00:00)
Title: Minimal clone example with separate network namespace.

Keith,

To bring you up to speed, Ravi had some issues getting clone+unshare to work. In short, the parent process (the clone caller) was terminating without wait()ing for the child process (the clone callee) to terminate. I think the clone system call needs SIGCHLD to be passed as a flag for wait() to work correctly. Otherwise, the callee is detached from the caller.

Ravi,

I have attached a minimal program that works. It clone()s bash in a new network namespace, just like your old program unsharenet, but using the clone command(). Also, because it wait()'s, it doesn't terminate until the spawned bash instance terminates. Once you clone() multiple programs, you should use waitpid() instead of wait() to wait on a specific child process.