[Zope-Checkins] SVN: Zope/trunk/ fixed handling of child processes in zopectl (DM)

Andreas Jung andreas at andreas-jung.com
Fri Nov 26 09:39:33 EST 2004


Log message for revision 28514:
  fixed handling of child processes in zopectl (DM)
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Zope/Startup/zopectl.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-11-26 14:20:00 UTC (rev 28513)
+++ Zope/trunk/doc/CHANGES.txt	2004-11-26 14:39:33 UTC (rev 28514)
@@ -46,6 +46,8 @@
 
     Bugs fixed
 
+      - zopectl: fixed handling of child processes (patch by Dieter Maurer)
+
       - Collector #1593: fixed dumb _get_id() implementation in
         OFS.CopySupport that produced copy_of_copy_of....files
 

Modified: Zope/trunk/lib/python/Zope/Startup/zopectl.py
===================================================================
--- Zope/trunk/lib/python/Zope/Startup/zopectl.py	2004-11-26 14:20:00 UTC (rev 28513)
+++ Zope/trunk/lib/python/Zope/Startup/zopectl.py	2004-11-26 14:39:33 UTC (rev 28514)
@@ -284,9 +284,23 @@
         c.do_status()
         c.cmdloop()
 
+def _ignoreSIGCHLD(*unused):
+    while 1:
+        try: os.waitpid(-1, os.WNOHANG)
+        except OSError: break
+
+
 if __name__ == "__main__":
     # we don't care to be notified of our childrens' exit statuses.
     # this prevents zombie processes from cluttering up the process
     # table when zopectl start/stop is used interactively.
-    signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+    # DM 2004-11-26: from the Linux "execve(2)" manual page:
+    #     Any signals set to be caught by the calling process are reset
+    #     to their default behaviour.
+    #     The SIGCHLD signal (when set to SIG_IGN) may or may not be reset
+    #     to SIG_DFL. 
+    #   If it is not reset, 'os.wait[pid]' can non-deterministically fail.
+    #   Thus, use a way such that "SIGCHLD" is definitely reset in children.
+    #signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+    signal.signal(signal.SIGCHLD, _ignoreSIGCHLD)
     main()



More information about the Zope-Checkins mailing list