Description
Is your feature request related to a problem?
If the user presses Ctrl-C in between the execution of an async function inside metacall, the metacall_destroy()
process doesn't happen, and there's an abrupt exit. This causes many deadlocks and issues, for example this.
Describe the solution you'd like
The solution should be implemented in the core itself to intercept the kill signal and call metacall_destroy()
to destroy the metacall process gracefully.
The signal handler can be implemented in C in the core (possibly bound to metacall_initialize()
itself), so that it starts listening as soon as a metacall instance is created. For cross-platform handling, we can refer this.
This can be done in a new signals
module. For now, we need to intercept SIGINT
and SIGTERM
(and maybe SIGHUP
).
First the loader will handle the Ctrl-C inside itself, then the core will destroy metacall and exit.
Describe alternatives you've considered
We can think of implementing it just at the loader level (for example, just for Node), but that will be specific to that language, and not very extensible. Implementing it in the core will make it a generalized solution and help later when we have async support for other languages too. Also, we would have to flexibility to handle more signals in future.