File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,10 @@ import (
55 "bytes"
66 "errors"
77 "io"
8+ "os"
89 "os/exec"
910 "regexp"
11+ "runtime"
1012 "time"
1113)
1214
@@ -55,8 +57,19 @@ func (c conn) Start() error {
5557
5658// Close closes conn's WriteCloser, ReadClosers, and waits for the command to finish.
5759func (c conn ) Close () error {
60+
5861 writeErr := c .WriteCloser .Close ()
5962 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+
6073 cmdErr := c .waitWithTimeout ()
6174
6275 if writeErr != nil {
@@ -67,6 +80,10 @@ func (c conn) Close() error {
6780 return readErr
6881 }
6982
83+ if interruptErr != nil {
84+ return interruptErr
85+ }
86+
7087 return cmdErr
7188}
7289
@@ -79,10 +96,14 @@ func (c conn) waitWithTimeout() error {
7996 go func () { result <- c .cmd .Wait () }()
8097 select {
8198 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+ }
83103 if brokenPipeRe .MatchString (c .stdErr .String ()) {
84104 return nil
85105 }
106+
86107 }
87108 return err
88109 case <- time .After (5 * time .Second ):
You can’t perform that action at this time.
0 commit comments