File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,10 @@ import (
5
5
"bytes"
6
6
"errors"
7
7
"io"
8
+ "os"
8
9
"os/exec"
9
10
"regexp"
11
+ "runtime"
10
12
"time"
11
13
)
12
14
@@ -55,8 +57,19 @@ func (c conn) Start() error {
55
57
56
58
// Close closes conn's WriteCloser, ReadClosers, and waits for the command to finish.
57
59
func (c conn ) Close () error {
60
+
58
61
writeErr := c .WriteCloser .Close ()
59
62
readErr := c .readerCloser .Close ()
63
+ var interruptErr error
64
+
65
+ if runtime .GOOS != "windows" {
66
+ // See https://github.com/bep/godartsass/issues/19
67
+ interruptErr = c .cmd .Process .Signal (os .Interrupt )
68
+ if interruptErr == os .ErrProcessDone {
69
+ interruptErr = nil
70
+ }
71
+ }
72
+
60
73
cmdErr := c .waitWithTimeout ()
61
74
62
75
if writeErr != nil {
@@ -67,6 +80,10 @@ func (c conn) Close() error {
67
80
return readErr
68
81
}
69
82
83
+ if interruptErr != nil {
84
+ return interruptErr
85
+ }
86
+
70
87
return cmdErr
71
88
}
72
89
@@ -79,10 +96,14 @@ func (c conn) waitWithTimeout() error {
79
96
go func () { result <- c .cmd .Wait () }()
80
97
select {
81
98
case err := <- result :
82
- if _ , ok := err .(* exec.ExitError ); ok {
99
+ if eerr , ok := err .(* exec.ExitError ); ok {
100
+ if eerr .Error () == "signal: interrupt" {
101
+ return nil
102
+ }
83
103
if brokenPipeRe .MatchString (c .stdErr .String ()) {
84
104
return nil
85
105
}
106
+
86
107
}
87
108
return err
88
109
case <- time .After (5 * time .Second ):
You can’t perform that action at this time.
0 commit comments