From 0fa4cd625f80af13c9b6f70e3bf0aebc2c8b755a Mon Sep 17 00:00:00 2001 From: soprea Date: Mon, 30 Nov 2020 20:54:02 +0100 Subject: [PATCH] Error handling for inputs (#316) 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 --- multiselect.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/multiselect.go b/multiselect.go index 0e434776..628abd72 100644 --- a/multiselect.go +++ b/multiselect.go @@ -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 }