Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: SIGINT (CTRL+C) causes choosenim to be killed with nim r program.nim #23573

Open
Alogani opened this issue May 5, 2024 · 0 comments
Open

Comments

@Alogani
Copy link

Alogani commented 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 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

@Alogani 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant