[Zope-Checkins] SVN: Zope/branches/2.9/ Merged from branches/slinkp-zopectl-exitcode-143813; fixes # 143813: zopectl should exit non-zero if child processes fail.

Paul Winkler pw_lists at slinkp.com
Fri Apr 25 15:19:25 EDT 2008


Log message for revision 85731:
  Merged from branches/slinkp-zopectl-exitcode-143813; fixes # 143813: zopectl should exit non-zero if child processes fail.

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/Zope2/Startup/zopectl.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.9/doc/CHANGES.txt	2008-04-25 19:10:27 UTC (rev 85730)
+++ Zope/branches/2.9/doc/CHANGES.txt	2008-04-25 19:19:25 UTC (rev 85731)
@@ -8,6 +8,9 @@
 
    Bugs fixed
 
+      - Launchpad #143813: zopectl now exits non-zero when
+        child processes fail.
+
       - Launchpad #143748: remove broken use of logging module in
         Products.Five.fiveconfigure.handleBrokenProduct.  Fixed by
         upgrading to Products.Five 1.3.11.

Modified: Zope/branches/2.9/lib/python/Zope2/Startup/zopectl.py
===================================================================
--- Zope/branches/2.9/lib/python/Zope2/Startup/zopectl.py	2008-04-25 19:10:27 UTC (rev 85730)
+++ Zope/branches/2.9/lib/python/Zope2/Startup/zopectl.py	2008-04-25 19:19:25 UTC (rev 85731)
@@ -138,6 +138,8 @@
 
 class ZopeCmd(ZDCmd):
 
+    _exitstatus = 0
+
     def _get_override(self, opt, name, svalue=None, flag=0):
         # Suppress the config file, and pass all configuration via the
         # command line.  This avoids needing to specialize the zdrun
@@ -203,7 +205,7 @@
             cmd += '[sys.argv.append(x) for x in %s];' % argv
         cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
         cmdline = self.get_startup_cmd(self.options.python, cmd)
-        os.system(cmdline)
+        self._exitstatus = os.system(cmdline)
 
     def help_run(self):
         print "run <script> [args] -- run a Python script with the Zope "
@@ -269,10 +271,11 @@
         # Parent process running (execv replaces process in child
         while True:
             try:
-                os.waitpid(pid, 0)
+                pid, status = os.waitpid(pid, 0)
             except (OSError, KeyboardInterrupt):
                 continue
             else:
+                self._exitstatus = status
                 break
 
     def help_test(self):
@@ -298,6 +301,8 @@
         print "program:", " ".join(options.program)
         c.do_status()
         c.cmdloop()
+    else:
+        return min(c._exitstatus, 1)
 
 def _ignoreSIGCHLD(*unused):
     while 1:
@@ -326,4 +331,5 @@
         # SIGCHILD is unset, just don't bother registering a SIGCHILD
         # signal handler at all.
         signal.signal(signal.SIGCHLD, _ignoreSIGCHLD)
-    main()
+    exitstatus = main()
+    sys.exit(exitstatus)



More information about the Zope-Checkins mailing list