HNHacker News
TopNewBestAskShowJobs

M9HF8wwiaAdZKEZ

5 karma · joined August 6, 2022

submissionscomments
M9HF8wwiaAdZKEZ··on Ctrl-C
Anything can keep ports locked for a bit (if either side doesn't properly close the connection). That's how TCP works. Set reuseaddr on your daemon's sockets.
M9HF8wwiaAdZKEZ··on Ctrl-C
> it should interrupt the current computation and let you resume your work without exiting the application

That's not what Ctrl+C is meant for or used for. It's used to terminate the running application, not the running task within that application.

If you want to be able to "resume your work" then you should press Ctrl+Z.

If you want something else then the application should probably be listening for some other keystroke. "Catch Ctrl+C and do something else" is a pretty awful idea for the very reason mentioned at the top of TFA (when you press Ctrl+C, it's to get out of whatever you're stuck in, so that you don't have to go open another terminal and type in killall ...)

M9HF8wwiaAdZKEZ··on Ctrl-C
As far as I can tell, this appears to be confusing Ctrl+C (SIGINT, which terminates a process, and is usually not restartable), with Ctrl+Z (SIGTSTP, which pauses a process, and is thus restartable).

The only software I can think of that could "restart" after a Ctrl+C is usually daemons or other long-lived processes (which already need to be able to "restart" after any kind of shutdown and thus have significant amounts of code dedicated to serializing and unserializing their internal state).

TFA even goes so far as to talk about memory leaks - which are completely irrelevant when your process is about to exit anyway!