summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-09-09 15:48:32 (GMT)
committerT. Wouters <thomas@python.org>2019-09-09 15:48:32 (GMT)
commit682107cf458578ee6bd92b7cc6862113034a4fad (patch)
treeccde00cbac424b2a41058fddb53c003d06ea8885 /Modules
parentd91d4de31745fc1ed4c7e6c208917827c9c472b6 (diff)
downloadcpython-682107cf458578ee6bd92b7cc6862113034a4fad.zip
cpython-682107cf458578ee6bd92b7cc6862113034a4fad.tar.gz
cpython-682107cf458578ee6bd92b7cc6862113034a4fad.tar.bz2
bpo-36279: Ensure os.wait3() rusage is initialized (GH-15111)
Co-Authored-By: David Wilson <dw@botanicus.net>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 81704ee..a0a2a30 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7489,6 +7489,12 @@ wait_helper(pid_t pid, int status, struct rusage *ru)
if (pid == -1)
return posix_error();
+ // If wait succeeded but no child was ready to report status, ru will not
+ // have been populated.
+ if (pid == 0) {
+ memset(ru, 0, sizeof(*ru));
+ }
+
if (struct_rusage == NULL) {
PyObject *m = PyImport_ImportModuleNoBlock("resource");
if (m == NULL)