about summary refs log tree commit diff stats
path: root/src/main.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-02-05 20:25:53 +0100
committerbptato <nincsnevem662@gmail.com>2025-02-05 20:41:58 +0100
commit03b1412771dd1d03676ec546b12432c352b88e4e (patch)
treede7ecc004f8a62af43e14cd3110758066a103d29 /src/main.nim
parent7f6cc3dc7d7f1c46dc56c7432244fca57a63a732 (diff)
downloadchawan-03b1412771dd1d03676ec546b12432c352b88e4e.tar.gz
pager: catch SIGINT for interrupt handler
Significantly more efficient in long running commands (as the context
switch is gone).

For many commands in quick succession...  it replaces the fcntl with
a tcsetattr, so I guess it's the same?
Diffstat (limited to 'src/main.nim')
-rw-r--r--src/main.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.nim b/src/main.nim
index e5d8d89b..54973779 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -275,7 +275,12 @@ proc main() =
   # make sure tmpdir exists
   discard mkdir(cstring(config.external.tmpdir), 0o700)
   let loaderPid = forkserver.loadConfig(config)
-  #setControlCHook(proc() {.noconv.} = quit(1))
+  onSignal SIGINT:
+    discard sig
+    if acceptSigint:
+      sigintCaught = true
+    else:
+      quit(1)
   let loaderControl = newSocketStream(loaderSockVec[0])
   loaderControl.setCloseOnExec()
   let client = newClient(config, forkserver, loaderPid, jsctx, warnings,