Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Error handling for inputs (#316)
Browse files Browse the repository at this point in the history
SIGHUP is ignored and the program gets into a weird loop waiting for select to happen.
Steps to reproduce:
`go run examples/longmulti.go`
In a different terminat run `kill -s hup (pidof longmulti)` Or simply close the terminal while the program waits for input.
The program is not killed and gets in a weird state slowly killing your CPU
  • Loading branch information
soprea authored Nov 30, 2020
1 parent 288b412 commit 0fa4cd6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion multiselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ func (m *MultiSelect) Prompt(config *PromptConfig) (interface{}, error) {

// start waiting for input
for {
r, _, _ := rr.ReadRune()
r, _, err := rr.ReadRune()
if err != nil {
return "", err
}
if r == '\r' || r == '\n' {
break
}
Expand Down

0 comments on commit 0fa4cd6

Please sign in to comment.