How to run a program in a new PID namespace? All tutorials on the internet show writing some custom C code in order to do it. Is there a command instead for that?
Asked
Active
Viewed 1,230 times
2 Answers
0
Try it with unshare -fp program
. This will fork the new program and put it inside the new PID namespace.
0
Try the unshare
program. Note that due to the way pid namespacing works you need to tell unshare to fork too. You may also want to get it to remount proc for you as well (which is possible in newer versions of the unshare
command I believe).

Matthew Ife
- 23,357
- 3
- 55
- 72
-
Trying on Ubuntu 14.04, I don't see any options related to PID namespaces, only mount, uts, ipc and net. – Ivan Oct 02 '15 at 14:36
-
Tried now on Centos 7, it has pid. But is giving 'fork: Cannot allocate memory' error. How to tell unshare to fork? – Ivan Oct 02 '15 at 14:41