Linux: SIGINT (CTRL+C) causes choosenim to be killed with nim r program.nim
Summary
Hello,
The actual behaviour
In linux, when compiling with nim r program.nim, using Ctrl+C (SIGINT signal) causes the whole program to quit, independently on how program.nim handles SIGINT.
Why I think it is wrong
I think the signal should be ignored by nim (or more precisely choosenim if I don't mistake) and handled directly in program.nim. This would allow to have programs that relies on SIGINT works correctly even when invoked with nim r program.nim (like cleanups, ignoring signals, etc.)
Possible solution
Normally, SIGINT is sent to all processes in the foreground, meaning that when doing nim r program.nim, it will be sent to both choosenim and program.nim (because program.nim stdin is the terminal, apart if program.nim has used some functions that could have disconnected (closing stdin, using tcsetpgrp? using setsid?))
So the solution is in choosenim to just ignore SIGINT (when nim r is used and after the program.nim has been executed) by doing :
signal(SIGINT, SIG_IGN)
# OR
onSignal(SIGINT):
discard
Description
Here is an example of behaviour of SIGINT when using nim r program.nim and throwing CTRL+C after program.nim has been launched
Traceback (most recent call last)
/__w/choosenim/choosenim/src/choosenimpkg/proxyexe.nim(62) proxyexe
/__w/choosenim/choosenim/src/choosenimpkg/proxyexe.nim(49) main
/__w/choosenim/choosenim/nimDir/lib/pure/osproc.nim(1397) waitForExit
SIGINT: Interrupted by Ctrl-C.
Alternatives
No response
Examples
No response
Backwards Compatibility
No response
Links
No response