Skip to content

Commit 57e1043

Browse files
committed
Fixes task kill --force on Windows
Process.Kill might still return an IsNotFound error, even if it actually killed the process. We should wait for the process to finish in the first place. Otherwise, when querying the task's status, we might still see it running, resulting in an error. Signed-off-by: Claudiu Belu <[email protected]>
1 parent d58542a commit 57e1043

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

task_opts.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,17 @@ func WithProcessKill(ctx context.Context, p Process) error {
158158
return err
159159
}
160160
if err := p.Kill(ctx, syscall.SIGKILL, WithKillAll); err != nil {
161-
if errdefs.IsFailedPrecondition(err) || errdefs.IsNotFound(err) {
161+
// Kill might still return an IsNotFound error, even if it actually
162+
// killed the process.
163+
if errdefs.IsNotFound(err) {
164+
select {
165+
case <-ctx.Done():
166+
return ctx.Err()
167+
case <-s:
168+
return nil
169+
}
170+
}
171+
if errdefs.IsFailedPrecondition(err) {
162172
return nil
163173
}
164174
return err

0 commit comments

Comments
 (0)