[issue21791] Proper return status of os.WNOHANG is not always (0, 0)

Davin Potts report at bugs.python.org
Mon Apr 27 19:02:43 CEST 2015


Davin Potts added the comment:

The man pages for waitpid on OpenBSD 5.x do not suggest any meaningful value will be returned in status when WNOHANG is requested and no child processes have anything to report.

The following session attempts to exercise os.waitpid using Python 2.7.9 on an OpenBSD 5.3 i386 system:
>>> import os
>>> os.spawnl(os.P_NOWAIT, '/bin/sleep', 'sleep', '10')
19491
>>> os.waitpid(-1, os.WNOHANG)
(0, 0)
>>> os.waitpid(-1, os.WNOHANG)   # wait a few seconds, try again
(0, 0)
>>> os.waitpid(-1, os.WNOHANG)   # waited long enough for sleep to exit
(19491, 0)
>>> os.waitpid(-1, os.WNOHANG)   # at this point, no children remain
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 10] No child processes


Can you provide any further information, like:
* OpenBSD docs that explain that we should expect non-zero values for status coming from waitpid?
* Example Python code to provoke the behavior originally described?
* Other suggestion of why OpenBSD's waitpid, which itself depends upon wait4, when called (the way Python calls it) with an already initialized status=0 and WNOHANG should return a modified value for status when the child had nothing to report?

----------
nosy: +davin
status: open -> pending

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


More information about the Python-bugs-list mailing list