Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix Closes issue: 3980: Rewrote addProcessToGroup. #3981

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions internal/externalcmd/cmd_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ func closeProcessGroup(h windows.Handle) error {
}

func addProcessToGroup(h windows.Handle, p *os.Process) error {
type process struct {
Pid int
Handle uintptr

// Combine the required access rights
access := uint32(windows.PROCESS_SET_QUOTA | windows.PROCESS_TERMINATE)

processHandle, err := windows.OpenProcess(access, false, uint32(p.Pid))
if err != nil {
return fmt.Errorf("failed to open process: %v", err)
}
defer windows.CloseHandle(processHandle)

return windows.AssignProcessToJobObject(h,
windows.Handle((*process)(unsafe.Pointer(p)).Handle))
err = windows.AssignProcessToJobObject(h, processHandle)
if err != nil {
return fmt.Errorf("failed to assign process to job object: %v", err)
}
return nil
}

func (e *Cmd) runOSSpecific(env []string) error {
Expand Down