Skip to content

Commit d6ca393

Browse files
authored
Merge pull request #4892 from mn-ram/fix/wsl2-bootscript-spin-loop
wsl2: stop spinning in for { <-ctx.Done() } after instance stop
2 parents 917327d + 89cb69d commit d6ca393

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

pkg/driver/wsl2/vm_windows.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ func provisionVM(ctx context.Context, instanceDir, instanceName, distroName stri
132132
"check /var/log/lima-init.log for more details (out=%q)", cmd.Args, err, string(out))
133133
}
134134

135-
for {
136-
<-ctx.Done()
137-
logrus.Info("Context closed, stopping vm")
138-
if status, err := getWslStatus(ctx, instanceName); err == nil &&
139-
status == limatype.StatusRunning {
140-
_ = stopVM(ctx, distroName)
141-
}
135+
<-ctx.Done()
136+
logrus.Info("Context closed, stopping vm")
137+
if status, err := getWslStatus(ctx, instanceName); err == nil &&
138+
status == limatype.StatusRunning {
139+
_ = stopVM(ctx, distroName)
142140
}
143141
}()
144142

0 commit comments

Comments
 (0)