Skip to content

Commit 1bd5f3f

Browse files
committed
try another fix
1 parent 879f2fa commit 1bd5f3f

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/itchio/headway v0.0.0-20251229214354-da882c8b5dd4
7-
github.com/itchio/ox v0.0.0-20260204011704-8e7bc5639671
7+
github.com/itchio/ox v0.0.0-20260212201121-1e6be0bfd382
88
github.com/stretchr/testify v1.11.1
99
golang.org/x/sys v0.40.0
1010
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ github.com/itchio/headway v0.0.0-20251229214354-da882c8b5dd4 h1:vOYjkMs+aVNeHU0d
66
github.com/itchio/headway v0.0.0-20251229214354-da882c8b5dd4/go.mod h1:1/4tbTrV3G/Su53pnKBpa5mv3cVkLweRAq/xRnulSQI=
77
github.com/itchio/ox v0.0.0-20260204011704-8e7bc5639671 h1:e78FK2tPyEA7uJlPhB36sqezp262LKuFsj8q/nPrdjM=
88
github.com/itchio/ox v0.0.0-20260204011704-8e7bc5639671/go.mod h1:433sW0ck7/e5u7yycn9pmuK84/askPuhm3MqtwFl9zk=
9+
github.com/itchio/ox v0.0.0-20260212201121-1e6be0bfd382 h1:FKGDIamOblBuLCYDxJkGEGCKZ5YG5gJvhCEXb6IcZA8=
10+
github.com/itchio/ox v0.0.0-20260212201121-1e6be0bfd382/go.mod h1:433sW0ck7/e5u7yycn9pmuK84/askPuhm3MqtwFl9zk=
911
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1012
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1113
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=

runner/processgroup_windows.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,11 @@ func (pg *processGroup) Wait() error {
122122
for {
123123
err := syscall.GetQueuedCompletionStatus(pg.ioPort, &completionCode, &completionKey, &overlapped, syscall.INFINITE)
124124
if err != nil {
125-
pg.cmd.Wait()
126125
waitDone <- err
127126
return
128127
}
129128

130129
if completionKey == magicCompletionKey && completionCode == syscallex.JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO {
131-
// Call cmd.Wait() to properly release the process handle.
132-
// Go 1.24+ panics if the process is GC'd without Wait().
133-
pg.cmd.Wait()
134130
waitDone <- nil
135131
return
136132
}
@@ -143,7 +139,9 @@ func (pg *processGroup) Wait() error {
143139
if pg.jobObject == syscall.InvalidHandle {
144140
pid := uint32(pg.cmd.Process.Pid)
145141
pg.consumer.Infof("Killing single process %d", pid)
146-
pg.cmd.Process.Kill()
142+
// Use terminateProcess instead of cmd.Process.Kill() because
143+
// the os.Process handle from os.FindProcess lacks PROCESS_TERMINATE.
144+
terminateProcess(pid, 1)
147145
} else {
148146
pg.consumer.Infof("Attempting to kill entire job object...")
149147
var processIdList syscallex.JobObjectBasicProcessIdList
@@ -184,16 +182,17 @@ func (pg *processGroup) Wait() error {
184182
}
185183
}
186184
}
187-
// Wait for the goroutine to finish, which calls cmd.Wait()
188-
// to properly release the process handle (required by Go 1.24+).
189-
<-waitDone
190185
case err := <-waitDone:
191186
pg.consumer.Infof("Wait done")
192187
if err != nil {
193188
return fmt.Errorf("%w", err)
194189
}
195190
}
196191

192+
// Close the raw process handle stored in SysProcAttr. This is a separate
193+
// handle from the one managed by os.Process and must be closed explicitly.
194+
syscall.CloseHandle(pg.cmd.SysProcAttr.ProcessHandle)
195+
197196
return nil
198197
}
199198

0 commit comments

Comments
 (0)