File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import (
18
18
"io"
19
19
"os/exec"
20
20
"strings"
21
+ "syscall"
21
22
"time"
22
23
23
24
"github.com/charmbracelet/gum/internal/exit"
48
49
bothbuf strings.Builder
49
50
outbuf strings.Builder
50
51
errbuf strings.Builder
52
+
53
+ executing * exec.Cmd
51
54
)
52
55
53
56
type finishCommandMsg struct {
@@ -64,11 +67,11 @@ func commandStart(command []string) tea.Cmd {
64
67
args = command [1 :]
65
68
}
66
69
67
- cmd : = exec .Command (command [0 ], args ... ) //nolint:gosec
68
- cmd .Stdout = io .MultiWriter (& bothbuf , & outbuf )
69
- cmd .Stderr = io .MultiWriter (& bothbuf , & errbuf )
70
- _ = cmd .Run ()
71
- status := cmd .ProcessState .ExitCode ()
70
+ executing = exec .Command (command [0 ], args ... ) //nolint:gosec
71
+ executing .Stdout = io .MultiWriter (& bothbuf , & outbuf )
72
+ executing .Stderr = io .MultiWriter (& bothbuf , & errbuf )
73
+ _ = executing .Run ()
74
+ status := executing .ProcessState .ExitCode ()
72
75
if status == - 1 {
73
76
status = 1
74
77
}
@@ -82,6 +85,13 @@ func commandStart(command []string) tea.Cmd {
82
85
}
83
86
}
84
87
88
+ func commandAbort () tea.Msg {
89
+ if executing != nil && executing .Process != nil {
90
+ _ = executing .Process .Signal (syscall .SIGINT )
91
+ }
92
+ return nil
93
+ }
94
+
85
95
func (m model ) Init () tea.Cmd {
86
96
return tea .Batch (
87
97
m .spinner .Tick ,
@@ -135,7 +145,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
135
145
switch msg .String () {
136
146
case "ctrl+c" :
137
147
m .aborted = true
138
- return m , tea . Quit
148
+ return m , commandAbort
139
149
}
140
150
}
141
151
You can’t perform that action at this time.
0 commit comments