Skip to content

Bad file descriptor errors from subprocess module in AIX #141659

@ayappanec

Description

@ayappanec

Bug report

Bug description:

# cat python-popen-script.py import subprocess p = subprocess.Popen(['ls', '-l']) # trace -a -x "./python python-popen-script.py" # trcrpt > capture_trcrpt # head -25 capture_trcrpt Mon Nov 17 02:43:50 2025 System: AIX 7.2 Node: fvtvios10 Machine: 00F905D14C00 Internet Address: 0972E2D7 9.114.226.215 At trace startup, the system contained 8 cpus, of which 8 were traced. Buffering: Kernel Heap This is from a 64-bit kernel. Tracing all hooks. trace -a -x ./python python-popen-script.py ID ELAPSED_SEC DELTA_MSEC APPL SYSCALL KERNEL INTERRUPT 101 0.000000000 0.000000 close LR = 101CB570 104 0.000000345 0.000345 return from close. error EBADF [0 usec] 101 0.000001187 0.000842 close LR = 101CB580 104 0.000001523 0.000336 return from close. error EBADF [0 usec] 101 0.000002361 0.000838 close LR = 101CB570 104 0.000002705 0.000344 return from close. error EBADF [0 usec] 101 0.000003541 0.000836 close LR = 101CB580 104 0.000003884 0.000343 return from close. error EBADF [0 usec] 101 0.000004734 0.000850 close LR = 101CB570 104 0.000005080 0.000346 return from close. error EBADF [0 usec] 101 0.000005919 0.000839 close LR = 101CB580 104 0.000006253 0.000334 return from close. error EBADF [0 usec] # grep EBADF capture_trcrpt | wc -l 21409 

Looks like _posixsubprocess module uses /proc/self/fd which is not available in AIX. Instead /proc/<PID>/fd should be used in AIX.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions