larkery / zsh-histdb

A slightly better history for zsh
MIT License
1.29k stars 75 forks source link

SIGINT trapped in macOS #142

Open atombender opened 4 months ago

atombender commented 4 months ago

I have a recurring problem with SIGINT being ignored in my shells, which I've been able to narrow down to zsh-histdb. Everything works as expected, except ctrl-c suddenly stops working in the shell. Executing trap INT {} restores the normal behaviour until it happens again. It's sporadic, but I can reproduce it very easily in about 5 seconds immediately after starting a shell.

I was using histdb for years before this showed up, but I can't pinpoint when it did. I've been able to reproduce this with a clean environment and only zsh-histdb, so this is definitely the cause.

I've not been able to reproduce it in the macOS Terminal.app, which is interesting, only in iTerm.

It sounds similar to #83, but probably something different.

Environment

atombender commented 4 months ago

I added an explicit trap, and have not seen the issue since. Not sure if this is the best fix, though:

$ git diff
diff --git a/sqlite-history.zsh b/sqlite-history.zsh
index c534918..dafe309 100644
--- a/sqlite-history.zsh
+++ b/sqlite-history.zsh
@@ -53,6 +53,7 @@ _histdb_start_sqlite_pipe () {
     local PIPE==(<<<'')
     setopt local_options no_notify no_monitor
     mkfifo $PIPE
+    TRAPINT() { return 1 }
     sqlite3 -batch -noheader "${HISTDB_FILE}" < $PIPE >/dev/null &|
     sysopen -w -o cloexec -u HISTDB_FD -- $PIPE
     command rm $PIPE