@@ -52,7 +52,7 @@ type SSHConn struct {
52
52
stdout io.ReadCloser
53
53
54
54
shutdownMtx sync.Mutex
55
- shutdownResult * shutdownResult
55
+ shutdownResult * shutdownResult // TODO not used anywhere
56
56
cmdCancel context.CancelFunc
57
57
}
58
58
@@ -151,24 +151,24 @@ func (conn *SSHConn) shutdownProcess() *shutdownResult {
151
151
return conn .shutdownResult
152
152
}
153
153
154
- termSuccessful := make (chan error , 1 )
154
+ wait := make (chan error , 1 )
155
155
go func () {
156
156
if err := conn .cmd .Process .Signal (syscall .SIGTERM ); err != nil {
157
157
// TODO log error
158
158
return
159
159
}
160
- termSuccessful <- conn .cmd .Wait ()
160
+ wait <- conn .cmd .Wait ()
161
161
}()
162
162
163
163
timeout := time .NewTimer (1 * time .Second ) // FIXME const
164
164
defer timeout .Stop ()
165
165
166
166
select {
167
- case waitErr := <- termSuccessful :
167
+ case waitErr := <- wait :
168
168
conn .shutdownResult = & shutdownResult {waitErr }
169
169
case <- timeout .C :
170
170
conn .cmdCancel ()
171
- waitErr := conn . cmd . Wait ()
171
+ waitErr := <- wait // reuse existing Wait invocation, must not call twice
172
172
conn .shutdownResult = & shutdownResult {waitErr }
173
173
}
174
174
return conn .shutdownResult
@@ -185,7 +185,7 @@ func (conn *SSHConn) Cmd() *exec.Cmd {
185
185
// which usually results in SIGKILL being sent to the process.
186
186
// Intended for integration tests, regular users shouldn't use it.
187
187
func (conn * SSHConn ) CmdCancel () {
188
- conn .cmdCancel ()
188
+ conn .cmdCancel ()
189
189
}
190
190
191
191
const bannerMessageLen = 31
0 commit comments