[issue11185] test_wait4 error on AIX

Sébastien Sablé report at bugs.python.org
Thu Feb 17 16:19:37 CET 2011


Sébastien Sablé <sable at users.sourceforge.net> added the comment:

This issue already existed on Python 2.5.2 with AIX 5.2:

http://www.mail-archive.com/python-list@python.org/msg192219.html

The documentation for WNOHANG says:
http://docs.python.org/library/os.html#os.WNOHANG
"""
The option for waitpid() to return immediately if no child process status is available immediately. The function returns (0, 0) in this case.
"""

It seems wait4 always returns 0 on AIX when WNOHANG is specified.

Removing WNOHANG will make the test succeed.

waitpid does not have the same limitation.

I suppose this is a bug of AIX, though there is not even a man page to describe wait4 on this platform.

Here is a proposition for a patch that will workaround this bug...

Index: Lib/test/test_wait4.py
===================================================================
--- Lib/test/test_wait4.py      (revision 88430)
+++ Lib/test/test_wait4.py      (working copy)
@@ -3,6 +3,7 @@
 
 import os
 import time
+import sys
 from test.fork_wait import ForkWait
 from test.support import run_unittest, reap_children, get_attribute
 
@@ -13,10 +14,14 @@
 
 class Wait4Test(ForkWait):
     def wait_impl(self, cpid):
+        option = os.WNOHANG
+        if sys.platform.startswith('aix'):
+            # wait4 is broken on AIX and will always return 0 with WNOHANG
+            option = 0
         for i in range(10):
             # wait4() shouldn't hang, but some of the buildbots seem to hang
             # in the forking tests.  This is an attempt to fix the problem.
-            spid, status, rusage = os.wait4(cpid, os.WNOHANG)
+            spid, status, rusage = os.wait4(cpid, option)
             if spid == cpid:
                 break
             time.sleep(1.0)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11185>
_______________________________________


More information about the Python-bugs-list mailing list