You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tests: simulated terminals leak into commands that other tests start #15216
The PTYs behind UCommand::terminal_simulation are opened with openpty, which doesn't set close-on-exec. While a test with a simulated terminal runs, every command another test thread starts inherits them, up to six descriptors.
That breaks tests that run under a low descriptor limit. On #15135, test_temporary_files_with_few_file_descriptors failed twice on the aarch64 Linux job: with the inherited descriptors, sort can't start gzip under a limit of 10 (log). With one thread running terminal-simulated commands, 275 of 300 commands started by another thread inherited PTY descriptors.
Two ways to fix it:
Open the PTY close-on-exec from the start where the OS supports it (Linux, Android, FreeBSD, NetBSD, through rustix), and set it right after openpty elsewhere. This closes the race on those systems.
Simpler: set close-on-exec right after openpty everywhere. That leaves a short window; in a tight loop 2 to 5 of 300 commands still inherited them.
Either way the harness has to keep the stdin PTY open until the child exits. Today that only works because the child inherits a copy of it.
Reproduced locally (Linux, aarch64): sort's -S 64K --compress-program gzip under a limit of 10, while 4 threads run terminal-simulated commands, failed 6 of 200 times with could not run compress program 'gzip': Too many open files. With #15217 applied it failed 0 of 200. With only 1 terminal thread it didn't fail, since too few descriptors leak at once.
Activity
abendrothj commentedon Oct 10, 2026
Reproduced locally (Linux, aarch64): sort's
-S 64K --compress-program gzipunder a limit of 10, while 4 threads run terminal-simulated commands, failed 6 of 200 times withcould not run compress program 'gzip': Too many open files. With #15217 applied it failed 0 of 200. With only 1 terminal thread it didn't fail, since too few descriptors leak at once.