fix: resolve interactive picker hang after fzf exits#16
Merged
ahmedelgabri merged 1 commit intomainfrom Feb 22, 2026
Merged
Conversation
Two bugs caused all interactive commands (add, remove, switch, destroy) to hang permanently after the fzf picker closed: 1. The fzf library does not close the Output channel when Run() returns, so the goroutine draining selected items via `range outputChan` blocked forever, deadlocking picker.Run() at wg.Wait(). 2. The fzf library registers signal.Notify for SIGINT/SIGTERM inside its terminal loop but never calls signal.Stop. After fzf exits, Go's runtime continued intercepting Ctrl-C and routing it to an unread channel, making the process unkillable. Additionally, switch ParseOptions from inheriting $FZF_DEFAULT_OPTS (which could introduce conflicting options in the embedded context) to using only the options we explicitly pass. Closes #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #15 — all interactive commands (
add,remove,switch,destroy) hung permanently after the fzf picker closed, and Ctrl-C was ineffective.Root cause: two bugs in
internal/picker/picker.go:Output channel deadlock — the fzf library does not close
opts.OutputwhenRun()returns. The goroutine draining selected items viafor s := range outputChanblocked forever, sowg.Wait()deadlocked andpicker.Run()never returned.Signal handling hijacked — fzf calls
signal.Notifyfor SIGINT/SIGTERM but never callssignal.Stop. After fzf exits, Go's runtime still intercepts Ctrl-C and routes it to the abandoned channel, making the process unkillable.Fix:
close(outputChan)afterfzf.Run()returns to unblock the draining goroutinesignal.Reset(os.Interrupt, syscall.SIGTERM)to restore default signal handlingParseOptions(false, ...)to avoid inheriting$FZF_DEFAULT_OPTSwhich could cause unexpected behavior in embedded useTest plan
go vetcleangit wt addinteractive mode — picker appears, selection works, Ctrl-C exits cleanlygit wt removeinteractive mode — picker appears, selection works, Ctrl-C exits cleanly