Nuitka icon indicating copy to clipboard operation
Nuitka copied to clipboard

How to disable killing my executable when receiving SIGINT in one file mode?

Open loaiali opened this issue 2 years ago • 3 comments

So I've been using nuitka3 for quite a while great work guys. I only had an issue that my executable gets killed by NUITKA after receiving SIGINT. Currently I'm handling this by using the flag --onefile-child-grace-time to be as big as possible. but I'm not very convinced with that. So I was asking if there's a clean way to tell NUITKA not to kill my executable on SIGINT?

loaiali avatar Feb 19 '23 11:02 loaiali

You can of course modify the source code, but that is a really important user request that nuitka by all means has to do that. Every time it failed to do so it has been treated as a usage impeding bug, so this is super critical.

Can you elabortate a bit more on the background of why you want this?

kayhayen avatar Feb 19 '23 11:02 kayhayen

Thanks @kayhayen for your reply, So what I'm trying to do is that I'm trying to implement a python script that behaves like a command prompt, so I would like the behavior of my python script in case a SIGINT arrives is that it just prints a newline that looks like this username> . I think I'll need to modify the source code then, I've given the source code a quick look and I think that what NUITKA does is that upon receiving a SIGINT it waits for the time defined in --onefile-child-grace-time then it sends SIGKILL signal to the client and that's the line I think I need to remove.

loaiali avatar Feb 19 '23 12:02 loaiali

So, basically it is that you want to be like CMD.EXE yourself and catch and pass sigint at your discretion, that makes sense to me. You still will have ignore sigint in your Python code, which I assume you already do. There could be an option in Nuitka to automatically ignore signals like this, that would be a nice enhancement then, and of course the way to include the onefile binary. To me it seems, you want to change the handling in ourConsoleCtrlHandler some.

I put this on the 1.6 milestone, but I think it will be added at some point, just not before 3.11 support.

kayhayen avatar Feb 19 '23 12:02 kayhayen