#endif
#include "util.h"
-#include <lib_internal/sys_unshare.h>
+#include <lib_internal/sys_clone.h>
#include <vserver.h>
}
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);
}
}
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);