access dereferences symbolic links. Use lstat instead.
[util-vserver.git] / src / vnamespace.c
index 076b4e4..d840fbb 100644 (file)
@@ -21,7 +21,7 @@
 #endif
 
 #include "util.h"
-#include <lib_internal/sys_unshare.h>
+#include <lib_internal/sys_clone.h>
 
 #include <vserver.h>
 
@@ -90,12 +90,24 @@ showVersion()
 static void
 newNamespace(void)
 {
-  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    :
+      vc_exitLikeProcess(pid, wrapper_exit_code);
   }
 }