diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2021-06-25 13:15:35 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 13:15:35 +0900 |
commit | 606611708c4351e9f5e0e3b975f9331d95168efb (patch) | |
tree | 38cf330854d59d9bb48d51c9edf2ae982cfe6804 /cli | |
parent | 66c5f41c5bd5fa08daa09f8650135000c1787829 (diff) |
fix(runtime/signal): use op_async_unref for op_signal_poll (#11097)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/tests/raw_mode_cbreak.ts | 12 | ||||
-rw-r--r-- | cli/tests/unit/signal_test.ts | 18 |
2 files changed, 25 insertions, 5 deletions
diff --git a/cli/tests/raw_mode_cbreak.ts b/cli/tests/raw_mode_cbreak.ts index 6506e89d7..b1c6d324b 100644 --- a/cli/tests/raw_mode_cbreak.ts +++ b/cli/tests/raw_mode_cbreak.ts @@ -5,11 +5,13 @@ const signal = Deno.signals.interrupt(); Deno.stdout.writeSync(new TextEncoder().encode("S")); -await signal; +signal.then(() => { + Deno.stdout.writeSync(new TextEncoder().encode("A")); -Deno.stdout.writeSync(new TextEncoder().encode("A")); + signal.dispose(); -signal.dispose(); + Deno.setRaw(0, false); // restores old mode. + Deno.setRaw(0, false); // Can be safely called multiple times +}); -Deno.setRaw(0, false); // restores old mode. -Deno.setRaw(0, false); // Can be safely called multiple times +setTimeout(() => {}, 10000); // Keep the program running diff --git a/cli/tests/unit/signal_test.ts b/cli/tests/unit/signal_test.ts index 9deca0837..340ec43eb 100644 --- a/cli/tests/unit/signal_test.ts +++ b/cli/tests/unit/signal_test.ts @@ -129,6 +129,24 @@ unitTest( }, ); +// This tests that pending op_signal_poll doesn't block the runtime from exiting the process. +unitTest( + { ignore: Deno.build.os === "windows", perms: { run: true, read: true } }, + async function signalStreamExitTest(): Promise<void> { + const p = Deno.run({ + cmd: [ + Deno.execPath(), + "eval", + "--unstable", + "(async () => { for await (const _ of Deno.signals.io()) {} })()", + ], + }); + const res = await p.status(); + assertEquals(res.code, 0); + p.close(); + }, +); + unitTest( { ignore: Deno.build.os === "windows", perms: { run: true } }, async function signalPromiseTest(): Promise<void> { |