Skip to content

Commit d6dec53

Browse files
committed
gh-144648: Improve libproc usage in _remote_debugging
Add a missing include and use proc_listpids rather than proc_listallpids, since it is functionally identical and more widely implemented.
1 parent 80ba4e1 commit d6dec53

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Modules/_remote_debugging/subprocess.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
273273

274274
#if defined(__APPLE__) && TARGET_OS_OSX
275275

276+
#include <libproc.h>
276277
#include <sys/proc_info.h>
277278

278279
static int
@@ -283,7 +284,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
283284
pid_t *ppids = NULL;
284285

285286
/* Get count of all PIDs */
286-
int n_pids = proc_listallpids(NULL, 0);
287+
int n_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
287288
if (n_pids <= 0) {
288289
PyErr_SetString(PyExc_OSError, "Failed to get process count");
289290
goto done;
@@ -298,7 +299,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result)
298299
}
299300

300301
/* Get actual PIDs */
301-
int actual = proc_listallpids(pid_list, buffer_size * sizeof(pid_t));
302+
int actual = proc_listpids(PROC_ALL_PIDS, 0, pid_list, buffer_size * sizeof(pid_t));
302303
if (actual <= 0) {
303304
PyErr_SetString(PyExc_OSError, "Failed to list PIDs");
304305
goto done;

0 commit comments

Comments
 (0)