bpo-36279: Ensure os.wait3() rusage is initialized (GH-15111)
Co-Authored-By: David Wilson <dw@botanicus.net>
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 @@
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)