vserver start: allow caller to wait for vserver to be started
authorSteve Muir <smuir@cs.princeton.edu>
Wed, 15 Jun 2005 22:04:47 +0000 (22:04 +0000)
committerSteve Muir <smuir@cs.princeton.edu>
Wed, 15 Jun 2005 22:04:47 +0000 (22:04 +0000)
python/vserver.py

index 39d15f2..64cc681 100644 (file)
@@ -193,7 +193,7 @@ class VServer:
         self.__do_chroot()
         self.__do_chcontext(state_file)
 
-    def start(self, runlevel = 3):
+    def start(self, wait, runlevel = 3):
 
         child_pid = os.fork()
         if child_pid == 0:
@@ -223,18 +223,19 @@ class VServer:
                 # XXX - we don't support all scripts that vserver script does
                 cmd_pid = 0
                 for cmd in self.INITSCRIPTS + [None]:
-                    # don't bother waiting for last command to terminate
-                    if cmd == None:
-                        os._exit(0)
-
-                    # wait for previous command to terminate
-                    if cmd_pid:
+                    # wait for previous command to terminate, unless it
+                    # is the last one and the caller has specified to wait
+                    if cmd_pid and (cmd != None or wait):
                         try:
                             os.waitpid(cmd_pid, 0)
                         except:
                             print >>log, "error waiting for %s:" % cmd_pid
                             traceback.print_exc()
 
+                    # end of list
+                    if cmd == None:
+                        os._exit(0)
+
                     # fork and exec next command
                     cmd_pid = os.fork()
                     if cmd_pid == 0: