D
Deno

help

How can I let my program keep running even if it receives SIGINT?

HMHong Minhee1/24/2023
I succeeded to write a program to handle SIGINT using Deno.addSignalListener("SIGINT", ...) API, but Deno always exits when it receives a SIGINT whether I put Deno.exit() inside the signal handler or not. [Edit: It was my mistake. Deno keeps running if a signal handler was registered.] I just want my program to reload the configuration file instead of terminating when it receives SIGINT. Is there any way to do it?
AAapoAlas1/24/2023
You can stop a program from existing by using beforeunload listener: https://deno.land/manual@v1.29.4/runtime/program_lifecycle#program-lifecycle
Deno
Program Lifecycle | Manual | Deno
Deno supports browser compatible lifecycle events:
AAapoAlas1/24/2023
If you call preventDefault() on the event it will, well, prevent the default handling from occurring which is to close the program.
HMHong Minhee1/24/2023
Sorry, it was my mistake. I tested again with a minimal example, and Deno apparently keeps running even if it receives SIGINT once after I registered a signal handler.
AAapoAlas1/24/2023
Ah, okay.

Looking for more? Join the community!