github.com/zaolin/u-root@v0.0.0-20200428085104-64aaafd46c6d/cmds/core/elvish/eval/interrupts.go (about) 1 package eval 2 3 import "errors" 4 5 // Interrupts returns a channel that is closed when an interrupt signal comes. 6 func (fm *Frame) Interrupts() <-chan struct{} { 7 return fm.intCh 8 } 9 10 var ErrInterrupted = errors.New("interrupted") 11 12 // IsInterrupted reports whether there has been an interrupt. 13 func (fm *Frame) IsInterrupted() bool { 14 select { 15 case <-fm.Interrupts(): 16 return true 17 default: 18 return false 19 } 20 }