//go:build windows package compose import ( "os/exec" "testing" "unsafe" "golang.org/x/sys/windows" ) func TestWindowsProcessJobUsesKillOnClose(t *testing.T) { job, err := newWindowsProcessJob() if err != nil { t.Fatal(err) } t.Cleanup(func() { if closeErr := job.close(); closeErr != nil { t.Error(closeErr) } }) var limits windows.JOBOBJECT_EXTENDED_LIMIT_INFORMATION if err := windows.QueryInformationJobObject( job.handle, windows.JobObjectExtendedLimitInformation, uintptr(unsafe.Pointer(&limits)), uint32(unsafe.Sizeof(limits)), nil, ); err != nil { t.Fatal(err) } if limits.BasicLimitInformation.LimitFlags&windows.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE == 0 { t.Fatalf("job limits = %#x, want JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE", limits.BasicLimitInformation.LimitFlags) } } func TestWindowsProcessConfigurationStartsSuspendedBeforeJobAssignment(t *testing.T) { command := exec.Command("docker") configureProcess(command) if command.SysProcAttr == nil || command.SysProcAttr.CreationFlags&createSuspendedProcess == 0 { t.Fatalf("configureProcess() flags = %#x, want CREATE_SUSPENDED", command.SysProcAttr.CreationFlags) } }