Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/signal/mod.ts>signal

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function signal
Deprecated
Deprecated

(will be removed in 1.0.0) Use the Deno signals API instead

import { signal } from "https://deno.land/std@0.201.0/signal/mod.ts";

Generates an AsyncIterable which can be awaited on for one or more signals. dispose() can be called when you are finished waiting on the events.

Example:

import { signal } from "https://deno.land/std@0.201.0/signal/mod.ts";

const sig = signal("SIGUSR1", "SIGINT");
setTimeout(() => {}, 5000); // Prevents exiting immediately

for await (const _ of sig) {
  // ..
}

// At some other point in your code when finished listening:
sig.dispose();

Parameters

...signals: [Deno.Signal, ...Deno.Signal[]]
  • one or more signals to listen to

Returns

AsyncIterable<void> & Disposable