std/signal/mod.ts

Deno standard library
Go to Latest
function signal
import { signal } from "https://deno.land/std@0.147.0/signal/mod.ts?s=signal";

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 "./mod.ts";

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

      for await (const _ of sig) {
        console.log("interrupt or usr1 signal received");
      }

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

Parameters

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

Returns

AsyncIterable<void> & Disposable[src]