Skip to content

Commit 47724d8

Browse files
[3.15] gh-156060: Do not scan every process four times in remote_debugging.get_child_pids() on macOS (GH-156061) (#156069)
1 parent 57dface commit 47724d8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Modules/_remote_debugging/subprocess.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
307307
PyErr_SetString(PyExc_OSError, "Failed to get process count");
308308
goto done;
309309
}
310+
n_pids /= sizeof(pid_t);
310311

311312
/* Allocate buffer for PIDs (add some slack for new processes) */
312313
int buffer_size = n_pids + 64;
@@ -322,6 +323,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
322323
PyErr_SetString(PyExc_OSError, "Failed to list PIDs");
323324
goto done;
324325
}
326+
actual /= sizeof(pid_t);
325327

326328
/* Build pid -> ppid mapping */
327329
ppids = (pid_t *)PyMem_Malloc(actual * sizeof(pid_t));

0 commit comments

Comments
 (0)