about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/ips/editor.nim19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/ips/editor.nim b/src/ips/editor.nim
index 5a172f79..a6a6623c 100644
--- a/src/ips/editor.nim
+++ b/src/ips/editor.nim
@@ -42,14 +42,17 @@ proc openEditor*(term: Terminal, config: Config, file: string, line = 1): bool =
   let cmd = formatEditorName(editor, file, line)
   term.quit()
   let wstatus = c_system(cstring(cmd))
-  result = WIFEXITED(wstatus) and WEXITSTATUS(wstatus) == 0
-  if not result:
-    # Hack.
-    #TODO this is a very bad idea, e.g. say the editor is writing into the
-    # file, then receives SIGINT, now the file is corrupted but Chawan will
-    # happily read it as if nothing happened.
-    # We should find a proper solution for this.
-    result = WIFSIGNALED(wstatus) and WTERMSIG(wstatus) == SIGINT
+  if wstatus == -1:
+    result = false
+  else:
+    result = WIFEXITED(wstatus) and WEXITSTATUS(wstatus) == 0
+    if not result:
+      # Hack.
+      #TODO this is a very bad idea, e.g. say the editor is writing into the
+      # file, then receives SIGINT, now the file is corrupted but Chawan will
+      # happily read it as if nothing happened.
+      # We should find a proper solution for this.
+      result = WIFSIGNALED(wstatus) and WTERMSIG(wstatus) == SIGINT
   term.restart()
 
 var tmpf_seq: int