X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvnamespace.c;h=c71cc9f8f0c3164d70c435965f31e06beae0b1d2;hb=4dd2d44ee45230e79b4797f162cdbbf767cad41c;hp=076b4e4b1351015dc80c058c5471edc17aa8b996;hpb=f32bc7966248cb1b9f3c535669db577cd022c369;p=util-vserver.git diff --git a/src/vnamespace.c b/src/vnamespace.c index 076b4e4..c71cc9f 100644 --- a/src/vnamespace.c +++ b/src/vnamespace.c @@ -21,7 +21,7 @@ #endif #include "util.h" -#include +#include #include @@ -88,14 +88,26 @@ showVersion() } static void -newNamespace(void) +newNamespace(char const *cmd) { - int rc; + pid_t pid; - rc = sys_unshare(CLONE_NEWNS); - if (rc!=0) { - perror("vnamespace: unshare()"); - exit(wrapper_exit_code); + signal(SIGCHLD, SIG_DFL); + +#ifdef NDEBUG + pid = sys_clone(CLONE_NEWNS|CLONE_VFORK|SIGCHLD, 0); +#else + pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0); +#endif + + switch (pid) { + case -1 : + perror("vnamespace: clone()"); + exit(wrapper_exit_code); + case 0 : + break; + default : + exitLikeProcess(pid, cmd, wrapper_exit_code); } } @@ -169,7 +181,7 @@ int main(int argc, char *argv[]) else if (optind==argc && (do_new || do_enter)) WRITE_MSG(2, "No command specified; try '--help' for more information\n"); else { - if (do_new) newNamespace(); + if (do_new) newNamespace(argv[optind]); else if (do_set) setNamespace(VC_SAMECTX, CLONE_NEWNS|CLONE_FS); else if (do_cleanup) cleanupNamespace(); else if (do_enter) enterNamespace(xid, CLONE_NEWNS|CLONE_FS);