Handle OS Signals

    • Use the flag to access new or unstable features in Deno.
    • Use the dispose() function of the Deno.signal SignalStream to stop watching the signal.

    You can use Deno.signal() function for handling OS signals:

    Deno.signal() also works as a promise:

      If you want to stop watching the signal, you can use method of the signal object:

      1. deno run --unstable dispose-signal.ts

      The above for-await loop exits after 5 seconds when sig.dispose() is called.