fix: lazysecrets starts from fzf's become, on a non-blocking terminal (#67)
fzf's become hands lazysecrets its /dev/tty still non-blocking. Go can't poll /dev/tty on macOS, so it reads it directly, and the TUI's first read failed with "resource temporarily unavailable" (EAGAIN). lazysecrets now makes a terminal on stdin blocking before the TUI starts (Unix; nothing on Windows). Reviewed-on: #67 Co-authored-by: Karl-Einar Bergstrøm <karl-einarb@outlook.com>
This commit was merged in pull request #67.
This commit is contained in:
1 parent
3e6db064ab
commit
4480e8fed0
3 files changed
+26
No files matched your search
@@ -436,6 +436,7 @@ Flags:
|
||||
Styles: &theme,
|
||||
DefaultFg: defaultFg,
|
||||
})
|
||||
blockingStdin()
|
||||
p = tea.NewProgram(m)
|
||||
final, err := p.Run()
|
||||
if fm, ok := final.(app.Model); ok {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//go:build !unix
|
||||
|
||||
package main
|
||||
|
||||
func blockingStdin() {}
|
||||
@@ -0,0 +1,20 @@
|
||||
//go:build unix
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// blockingStdin makes a terminal on stdin blocking again. fzf's become
|
||||
// hands on its /dev/tty non-blocking; Go can't poll /dev/tty on macOS,
|
||||
// so it reads it directly, and the TUI's first read would fail with
|
||||
// EAGAIN ("resource temporarily unavailable").
|
||||
func blockingStdin() {
|
||||
if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) {
|
||||
_ = syscall.SetNonblock(fd, false)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user