lxcsu proc bug fix
[lxc-userspace.git] / lxcsu-internal
index 184b68f..a670d62 100755 (executable)
@@ -80,7 +80,7 @@ def main ():
                 slice_path = path
                 pid = slice_path.split('/')[2]
                 cmdline = open('/proc/%s/cmdline'%pid).read().rstrip('\n\x00')
-                if (cmdline == '/sbin/init'):
+                if (cmdline == '/sbin/init') or (cmdline.startswith("init [")):
                     slice_spec = slice_path
                     arch = getarch('/proc/%s/exe'%pid)
                     break
@@ -152,9 +152,13 @@ def main ():
     if (not args.pidns):
         setns.chcontext('/proc/%s/ns/pid'%pid)
 
+    proc_mounted = False
     if (not os.access('/proc/self',0)):
+        proc_mounted = True
         setns.proc_mount()
 
+    
+
     # cgroups is not yet LXC-safe, so we need to use the course grained access control
     # strategy of unmounting the filesystem
 
@@ -185,6 +189,7 @@ def main ():
         if debug: print 'lxcsu-internal:execv:','/usr/bin/setarch',exec_args
         os.execv('/usr/bin/setarch',exec_args)
     else:
+        setns.proc_umount()
         _,status = os.waitpid(pid,0)
         exit(os.WEXITSTATUS(status))