fix(auth): harden unified diagnostic execution
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
//go:build windows
|
||||
|
||||
package compose
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
const finalTerminationBound = 2 * time.Second
|
||||
const createNewProcessGroup = 0x00000200
|
||||
|
||||
func configureProcess(command *exec.Cmd) {
|
||||
command.SysProcAttr = &syscall.SysProcAttr{CreationFlags: createNewProcessGroup}
|
||||
}
|
||||
|
||||
func terminateProcess(command *exec.Cmd, done <-chan error) error {
|
||||
if command.Process == nil {
|
||||
return nil
|
||||
}
|
||||
_ = command.Process.Kill()
|
||||
select {
|
||||
case <-done:
|
||||
return nil
|
||||
case <-time.After(finalTerminationBound):
|
||||
return errors.New("Docker command could not be reaped")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user