Skip to content
Source
Sign inSign up
pingdotgg/t3code

test(ssh): zombie-reap launch test no longer races the shell #20052

Closedtris203(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/20052/headopened View on GitHub

Showing 1 changed file with 15 additions and 13 deletions.

x
0 of 1 viewed, 1 left
15 additions and 13 deletionspackages/ssh/src/tunnel.test.tsModified
View file
@@ -1451,26 +1451,28 @@
// A crashed server whose parent never reaps it stays a zombie, which
// kill -0 still reports. Its pid file and runtime record keep naming it.
+ // The child is killed only after sh has exec'd into node, which never
+ // reaps it (sh would), and its pid is printed once SIGCHLD confirms the
+ // zombie exists.
const parent = yield* spawner.spawn(
- ChildProcess.make("sh", ["-c", "sleep 600 & echo $!; exec sleep 600"]),
+ ChildProcess.make("sh", [
+ "-c",
+ 'sleep 600 & exec node -e "$1" "$!"',
+ "sh",
+ [
+ "const child = Number(process.argv[1]);",
+ 'process.on("SIGCHLD", () => console.log(child));',
+ 'process.kill(child, "SIGKILL");',
+ "setInterval(() => {}, 1 << 30);",
+ ].join("\n"),
+ ]),
const zombie = Number(
Option.getOrThrow(
yield* parent.stdout.pipe(Stream.decodeText(), Stream.splitLines, Stream.runHead),
- process.kill(zombie, "SIGKILL");
- // SIGKILL delivery is asynchronous; establish the zombie fixture before launching.
- const zombieState = yield* runScript(home, [
- "-c",