Skip to content

Commit c49ac91

Browse files
test(ssh): wait for the killed process to become a zombie
1 parent ef35995 commit c49ac91

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎packages/ssh/src/tunnel.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,17 @@ server.listen(Number(flag("--port")), "127.0.0.1", () => {
14601460
),
14611461
);
14621462
process.kill(zombie, "SIGKILL");
1463-
assert.include((yield* runScript(home, ["-c", `ps -o stat= -p ${zombie}`])).stdout, "Z");
1463+
// SIGKILL delivery is asynchronous; establish the zombie fixture before launching.
1464+
const zombieState = yield* runScript(home, [
1465+
"-c",
1466+
`attempt=0; while [ "$attempt" -lt 100 ]; do
1467+
state=$(ps -o stat= -p ${zombie}) || exit 1
1468+
case "$state" in *Z*) printf '%s\\n' "$state"; exit 0;; esac
1469+
attempt=$((attempt + 1))
1470+
done; printf '%s\\n' "$state"; exit 1`,
1471+
]);
1472+
assert.equal(zombieState.exitCode, 0, zombieState.stdout);
1473+
assert.include(zombieState.stdout, "Z");
14641474
yield* fs.writeFileString(`${stateDir}/pid`, `${zombie}\n`);
14651475
yield* fs.writeFileString(
14661476
`${home}/.t3/userdata/server-runtime.json`,

0 commit comments

Comments
 (0)