Skip to content

Commit d9615e2

Browse files
callthingsoffArkaSaha30
authored andcommitted
[3.5]backport: pkg/expect: avoid hardcoding when checking ErrProcessDone
ExpectProcess's Stop method uses 'strings.Contains' to check the returned err, however, this can be avoided. os.ErrProcessDone's error message is the same as the hardcoded string. So I think this explicit error is what this method wants to compare. Signed-off-by: Jes Cok <[email protected]>
1 parent 0bcdc34 commit d9615e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/expect/expect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (ep *ExpectProcess) ExitError() error {
286286
// Stop signals the process to terminate via SIGTERM
287287
func (ep *ExpectProcess) Stop() error {
288288
err := ep.Signal(syscall.SIGTERM)
289-
if err != nil && strings.Contains(err.Error(), "os: process already finished") {
289+
if err != nil && errors.Is(err, os.ErrProcessDone) {
290290
return nil
291291
}
292292
return err

0 commit comments

Comments
 (0)