From 78093a5eb0cf370a007b784649edf07861ae5334 Mon Sep 17 00:00:00 2001 From: Ayappan P Date: Mon, 17 Nov 2025 08:05:47 -0500 Subject: [PATCH 1/5] pythongh-141659: Fix bad file descriptor errors from subprocess on AIX --- Modules/_posixsubprocess.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 0219a3360fd6b1..931752279ddcd2 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -514,7 +514,13 @@ _close_open_fds_maybe_unsafe(int start_fd, int *fds_to_keep, proc_fd_dir = NULL; else #endif +#if defined(_AIX) + char fd_path[PATH_MAX]; + snprintf(fd_path, sizeof(fd_path), "/proc/%ld/fd", (long)getpid()); + proc_fd_dir = opendir(fd_path); +#else proc_fd_dir = opendir(FD_DIR); +#endif if (!proc_fd_dir) { /* No way to get a list of open fds. */ _close_range_except(start_fd, -1, fds_to_keep, fds_to_keep_len, From c68cb8d33db13eb8b6d82b3abf56c2d884bf972e Mon Sep 17 00:00:00 2001 From: Ayappan P Date: Mon, 17 Nov 2025 08:18:26 -0500 Subject: [PATCH 2/5] Add NEWS entry --- .../2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst b/Misc/NEWS.d/next/Core and Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst new file mode 100644 index 00000000000000..2722704de2f039 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst @@ -0,0 +1 @@ +Fix bad file descriptor errors from ``_posixsubprocess`` on AIX From e527bcb36f8b132689c9278f449521d37489f33d Mon Sep 17 00:00:00 2001 From: Ayappan P Date: Mon, 17 Nov 2025 08:50:19 -0500 Subject: [PATCH 3/5] Fix trailing whitespaces --- Modules/_posixsubprocess.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 931752279ddcd2..6f0a6d1d4e37fe 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -515,8 +515,8 @@ _close_open_fds_maybe_unsafe(int start_fd, int *fds_to_keep, else #endif #if defined(_AIX) - char fd_path[PATH_MAX]; - snprintf(fd_path, sizeof(fd_path), "/proc/%ld/fd", (long)getpid()); + char fd_path[PATH_MAX]; + snprintf(fd_path, sizeof(fd_path), "/proc/%ld/fd", (long)getpid()); proc_fd_dir = opendir(fd_path); #else proc_fd_dir = opendir(FD_DIR); From 4ae34d54f1a5b7e2e45a2f14a96fede2e994d712 Mon Sep 17 00:00:00 2001 From: Ayappan P Date: Mon, 17 Nov 2025 08:53:14 -0500 Subject: [PATCH 4/5] Fix NEWS entry --- .../2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{Core and Builtins => Core_and_Builtins}/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst (100%) diff --git a/Misc/NEWS.d/next/Core and Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst similarity index 100% rename from Misc/NEWS.d/next/Core and Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst rename to Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst From 790d9c3122c46cd40e240997052e8498124b56ca Mon Sep 17 00:00:00 2001 From: Ayappan Perumal Date: Tue, 18 Nov 2025 09:50:15 +0530 Subject: [PATCH 5/5] Update Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- .../2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst index 2722704de2f039..eeb055c6012a12 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst @@ -1 +1 @@ -Fix bad file descriptor errors from ``_posixsubprocess`` on AIX +Fix bad file descriptor errors from ``_posixsubprocess`` on AIX.