summaryrefslogtreecommitdiff
path: root/tests/unit/signal_test.ts
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-03-11 10:22:28 -0700
committerGitHub <noreply@github.com>2024-03-11 10:22:28 -0700
commit28b362adfc49324e20af5ecb1530f89eb91c4ed5 (patch)
treec0e5cc5b08d13a2a10f2f72281996090356af61c /tests/unit/signal_test.ts
parent670e9a9be78e15c2800541aeba62d7cba6a4d58d (diff)
fix(runtime): Restore default signal handler after user handlers are unregistered (#22757)
<!-- Before submitting a PR, please read https://docs.deno.com/runtime/manual/references/contributing 1. Give the PR a descriptive title. Examples of good title: - fix(std/http): Fix race condition in server - docs(console): Update docstrings - feat(doc): Handle nested reexports Examples of bad title: - fix #7123 - update docs - fix bugs 2. Ensure there is a related issue and it is referenced in the PR text. 3. Ensure there are tests that cover the changes. 4. Ensure `cargo test` passes. 5. Ensure `./tools/format.js` passes without changing files. 6. Ensure `./tools/lint.js` passes. 7. Open as a draft PR if your work is still in progress. The CI won't run all steps, but you can add '[ci]' to a commit message to force it to. 8. If you would like to run the benchmarks on the CI, add the 'ci-bench' label. --> Fixes #22724. Fixes #7164. This does add a dependency on `signal-hook`, but it's just a higher level API on top of `signal-hook-registry` (which we and `tokio` already depend on) and doesn't add any transitive deps.
Diffstat (limited to 'tests/unit/signal_test.ts')
-rw-r--r--tests/unit/signal_test.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit/signal_test.ts b/tests/unit/signal_test.ts
index 2ba2ffb15..1d9b10ae7 100644
--- a/tests/unit/signal_test.ts
+++ b/tests/unit/signal_test.ts
@@ -172,10 +172,20 @@ Deno.test(
}
// Sends SIGUSR1 (irrelevant signal) 3 times.
+ // By default SIGUSR1 terminates, so set it to a no-op for this test.
+ let count = 0;
+ const irrelevant = () => {
+ count++;
+ };
+ Deno.addSignalListener("SIGUSR1", irrelevant);
for (const _ of Array(3)) {
await delay(20);
Deno.kill(Deno.pid, "SIGUSR1");
}
+ while (count < 3) {
+ await delay(20);
+ }
+ Deno.removeSignalListener("SIGUSR1", irrelevant);
// No change
assertEquals(c, "010101000");