Skip to content

Commit c084b7c

Browse files
authored
Make the shell cancellation fixture ready for immediate TERM (#1489)
1 parent bd49bd6 commit c084b7c

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

‎packages/cli/tests/stdin-cli.test.ts‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -654,19 +654,24 @@ describe(
654654
stderr: "",
655655
});
656656

657-
const run = yield* spawn(function* () {
658-
// A large trailing write, so what is asserted below is the whole of it
659-
// rather than the first line to arrive.
660-
yield* runShell("trap 'yes LATE | head -20000; exit 0' TERM; echo READY; sleep 20", {
661-
stdin: "",
662-
timeout: 60_000,
663-
observeChild: (started, reader) => {
664-
child = started;
665-
before = attached(started);
666-
captured = reader;
667-
},
668-
}).join();
669-
});
657+
const run = yield* spawn(() =>
658+
useFixture({}, function* (dir) {
659+
// The shell keeps both ends of the FIFO open so its builtin read
660+
// can block without a foreground child deferring the TERM trap.
661+
const command =
662+
"mkfifo hold && exec 3<>hold && trap 'yes LATE | head -20000; exit 0' TERM && echo READY && read -r line <&3";
663+
yield* runShell(command, {
664+
cwd: dir,
665+
stdin: "",
666+
timeout: 60_000,
667+
observeChild: (started, reader) => {
668+
child = started;
669+
before = attached(started);
670+
captured = reader;
671+
},
672+
}).join();
673+
}),
674+
);
670675

671676
// Synchronized on the child running, so the halt lands on a live process
672677
// with every handler attached.

0 commit comments

Comments
 (0)