https://github.com/python/cpython/commit/7cb15f93fe53931aae9fc0e61e07354fd66cab9c
commit: 7cb15f93fe53931aae9fc0e61e07354fd66cab9c
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-11-19T08:05:01Z
summary:

[3.14] gh-141659: Fix bad file descriptor error in subprocess on AIX 
(GH-141660) (GH-141738)

/proc/self does not exist on AIX.
(cherry picked from commit 92c5de73b8d7526326c865b1a669b868f0d40c1e)

Co-authored-by: Ayappan Perumal <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2025-11-17-08-16-30.gh-issue-141659.QNi9Aj.rst
M Modules/_posixsubprocess.c

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..eeb055c6012a12
--- /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.
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 6ce3494e778df3..e0a95318afe988 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,

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to