mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-30 06:51:59 -08:00
fix closing some custom commands on Windows (#3981)
Some checks failed
code_lint / golangci_lint (push) Has been cancelled
code_lint / mod_tidy (push) Has been cancelled
code_lint / api_docs (push) Has been cancelled
code_test / test_64 (push) Has been cancelled
code_test / test_32 (push) Has been cancelled
code_test / test_highlevel (push) Has been cancelled
Some checks failed
code_lint / golangci_lint (push) Has been cancelled
code_lint / mod_tidy (push) Has been cancelled
code_lint / api_docs (push) Has been cancelled
code_test / test_64 (push) Has been cancelled
code_test / test_32 (push) Has been cancelled
code_test / test_highlevel (push) Has been cancelled
* Bugfix: Rewrote addProcessToGroup. Fixed possible invalid process handle by using windows.OpenProcess instead. Fixes issue: 3980 * run gofumpt --------- Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
This commit is contained in:
parent
8f04264fe5
commit
8c1ed7254f
1 changed files with 13 additions and 5 deletions
|
|
@ -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)
|
||||
|
||||
err = windows.AssignProcessToJobObject(h, processHandle)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to assign process to job object: %v", err)
|
||||
}
|
||||
|
||||
return windows.AssignProcessToJobObject(h,
|
||||
windows.Handle((*process)(unsafe.Pointer(p)).Handle))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Cmd) runOSSpecific(env []string) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue