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

/proc/self does not exist on AIX.
This commit is contained in:
Ayappan Perumal 2025-11-19 13:07:09 +05:30 committed by GitHub
parent 7b0b708675
commit 92c5de73b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -0,0 +1 @@
Fix bad file descriptor errors from ``_posixsubprocess`` on AIX.

View file

@ -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,