This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: BSD-style wait4 implementation
Type: Stage:
Components: Extension Modules Versions: Python 2.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: cjschr, jepler, loewis, nnorwitz
Priority: normal Keywords: patch

Created on 2004-07-29 18:52 by cjschr, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
my-wait4.py cjschr, 2004-08-13 18:59 wait4 usage example
test_wait4.py cjschr, 2004-08-13 19:13 A wait4 test suite
resourcemodule.h cjschr, 2005-06-01 22:18 resource module header for wait4 implementation
wait4.diff cjschr, 2005-08-01 22:50 wait4 patch
Messages (10)
msg46482 - (view) Author: chads (cjschr) Date: 2004-07-29 18:52
A BSD-style wait4 implementation.

Using existing code from the posixmodule.c and
resource.c files,
I threw together a patch that implements the wait4
function.

This function is similar to waitpid, but it also
returns usage information
about the child process.

wait4(pid, options) -> (pid, status, rusage)

It works for me on RedHat Linux 9 and FreeBSD 4.5 boxes
using
Python-2.3.4.

The patch may need some fine tuning.

Thanks
Chad
msg46483 - (view) Author: Jeff Epler (jepler) Date: 2004-08-04 21:53
Logged In: YES 
user_id=2772

You should also add code to the test suite to test wait4
when it is available.
msg46484 - (view) Author: chads (cjschr) Date: 2004-08-13 19:00
Logged In: YES 
user_id=1093928

Added a test suite and an example of using wait4.  Feedback
is welcome.
Thanks.
msg46485 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-08-22 16:23
Logged In: YES 
user_id=21627

struct rusage is already defined in
Modules/resourcemodule.c. It would be good if there was only
a single definition of the type object.

To achieve this, resourcemodule.c should expose a C API (e.g. 

  PyObject *PyResource_FromResource(struct rusage*)

). This should be put into a CObject, which should be
published through the module; then posixmodule should import
resource when wait4 is called for the first time.

Alternative, wait4 could be added to resourcemodule.c entirely.

Yet another alternative, on top of this approach,
posixmodule and/or os.py could provide their own definition
of wait4 which delegates to resource.wait4 on first usage.
msg46486 - (view) Author: chads (cjschr) Date: 2005-05-18 20:32
Logged In: YES 
user_id=1093928

Finally took the time to implement os.wait4 based the
comments from
loewis.  Added a resourcemodule.h header and modified
resource.c and
posixmodule.c appropriately.

Take a gander and let me know what you think.
Thanks.

msg46487 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-05-24 21:15
Logged In: YES 
user_id=21627

The code looks fine. The only problem I have with it that it
seems to assume that any POSIX system implements wait4.
However, I don't see it in Single Unix V3, so I think there
should be some configure test to determine whether the
function is present.

Also, it would be nice if the resource module was only
imported if wait4 was actually called.

I can't see documentation changes; please provide a patch
for Doc/lib/libos.tex as well.

If you resubmit the patch, it would be easiest if the patch
was a single file, eg. generated with "cvs diff -u". There
is no need to include configure changes; configure.in would
be sufficient.
msg46488 - (view) Author: chads (cjschr) Date: 2005-06-01 22:18
Logged In: YES 
user_id=1093928

Per Martin's suggestions - thanks again.
Documentation additions, configure test, import when called,
single diff.

LMK how this one fairs.
msg46489 - (view) Author: chads (cjschr) Date: 2005-08-01 22:50
Logged In: YES 
user_id=1093928

Fix compilation error (gcc-2.95).

Has anyone had a chance to look at this for inclusion?
msg46490 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2005-10-01 03:16
Logged In: YES 
user_id=33168

Dup: 1309579.  Not sure which is most up-to-date.  Waiting
for Chad to advise.
msg46491 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2005-10-02 21:57
Logged In: YES 
user_id=33168

Received mail from author, this is out of date, newer patch
is up-to-date.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40658
2004-07-29 18:52:51cjschrcreate