8

If I press Ctrl-C while my program is running it exits and prints SIGINT: Interrupted by Ctrl-C.

How do I ignore the Ctrl-C interrupt in Nim on Linux? Thanks in advance.

joe
  • 463
  • 4
  • 17

1 Answers1

11

You can control the behaviour of Ctrl+C with setControlCHook:

proc ctrlc() {.noconv.} =
  echo "Ctrl+C fired!"

setControlCHook(ctrlc)

Now CtrlC calls the ctrlc procedure. It's up to that procedure to ignore the SIGINT, or to clean the house and exit with quit.

xbello
  • 7,223
  • 3
  • 28
  • 41