MCPcopy Index your code
hub / github.com/coder/coder / installSignalHandler

Function installSignalHandler

cli/cliui/select.go:25–51  ·  view source on GitHub ↗
(p *tea.Program)

Source from the content-addressed store, hash-verified

23type terminateMsg struct{}
24
25func installSignalHandler(p *tea.Program) func() {
26 ch := make(chan struct{})
27
28 go func() {
29 sig := make(chan os.Signal, 1)
30 signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
31
32 defer func() {
33 signal.Stop(sig)
34 close(ch)
35 }()
36
37 for {
38 select {
39 case <-ch:
40 return
41
42 case <-sig:
43 p.Send(terminateMsg{})
44 }
45 }
46 }()
47
48 return func() {
49 ch <- struct{}{}
50 }
51}
52
53type SelectOptions struct {
54 Options []string

Callers 2

SelectFunction · 0.85
MultiSelectFunction · 0.85

Calls 3

StopMethod · 0.65
SendMethod · 0.65
NotifyMethod · 0.45

Tested by

no test coverage detected