test(wsl): hand the reap test's fake cat its real stdin (#34352)

* test(wsl): hand the reap test's fake cat its real stdin

The fake cat backgrounded the real cat with `&`, which a non-interactive sh starts on
/dev/null (dash even under `<&0`). The socket reader therefore ended at once, before orcad
hung up, and the relay killed its partner, sometimes before that cat's TERM trap was set:
on Linux under load the trap count stayed at 1 even after #34329 (3 of 6 rounds of 50
failed). The fake cat now passes stdin on fd 5, as the relay itself does, so the socket
reader ends only when orcad hangs up and the stdin reader blocks until killed.

* test(wsl): mark the fake cat armed only once its child is known; tighten the comment
This commit is contained in:
Neil
2026-10-27 02:36:25 -07:00
committed by GitHub
parent 433d044d65
commit 2dca6a8eb2
+4 -6
View File
@@ -274,12 +274,10 @@ describe.runIf(RELAY)('the bash stdio bridge', () => {
join(bin, 'cat'),
'#!/bin/sh\n' +
`trap 'kill $c 2>/dev/null; sleep 0.3; : > "${join(dir, 'killed')}"; exit 0' TERM\n` +
`: > "${join(dir, 'trap')}.$$"\n` +
`${realCat()} "$@" & c=$!\nwait $c\n` +
// The relay's socket is fd 3: its reader (stdin is fd 3) ends with orcad; the stdin reader
// stays blocked, as on a real host where the desktop keeps its pipe open, until killed.
'[ /dev/fd/0 -ef /dev/fd/3 ] && exit 0\n' +
'sleep 30 & c=$!\nwait $c\n',
// POSIX gives a background job /dev/null as stdin even under `<&0`, so hand it over on fd 5
// as the relay does: the socket reader ends with orcad, the stdin reader blocks until killed.
`exec 5<&0\n${realCat()} "$@" <&5 & c=$!\nexec 5<&-\n` +
`: > "${join(dir, 'trap')}.$$"\nwait $c\n`,
{ mode: 0o755 }
)
const trapsSet = (): number =>