Skip to content

Commit d2d2459

Browse files
authored
gh-144648: Improve libproc usage in _remote_debugging (#144649)
1 parent 704b915 commit d2d2459

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allowed _remote_debugging to build on more OS versions by using proc_listpids() rather than proc_listallpids().

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)