You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Alogani
changed the title
Linux: SIGINT (CTRL+C) cause choosnim to be killed with nim r program.nim
Linux: SIGINT (CTRL+C) causes choosnim to be killed with nim r program.nim
May 5, 2024
Alogani
changed the title
Linux: SIGINT (CTRL+C) causes choosnim to be killed with nim r program.nim
Linux: SIGINT (CTRL+C) causes choosenim to be killed with nim r program.nim
May 5, 2024
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 howprogram.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 withnim 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 :Description
Here is an example of behaviour of SIGINT when using
nim r program.nim
and throwing CTRL+C afterprogram.nim
has been launchedAlternatives
No response
Examples
No response
Backwards Compatibility
No response
Links
No response
The text was updated successfully, but these errors were encountered: