Module

std/signal/mod.ts>onSignal

Deno standard library
Go to Latest
function onSignal
Deprecated
Deprecated

Use Deno.addSignalListener and Deno.removeSignalListener instead.

import { onSignal } from "https://dotland.deno.dev/std@0.116.0/signal/mod.ts";

Registers a callback function to be called on triggering of a signal event.

      import { onSignal } from "./mod.ts";

      const handle = onSignal("SIGINT", () => {
        console.log('Received SIGINT');
        handle.dispose();  // de-register from receiving further events
      });

Parameters

signal: Deno.Signal

One of Deno.Signal (e.g. "SIGINT")

callback: () => void

Callback function triggered upon signal event