{"record":{"id":"7ebba8ef022ea723","repo":"GoogleContainerTools/skaffold","slug":"could-not-get-handle-from-process-w","errorCode":null,"errorMessage":"could not get handle from process: %w","messagePattern":"could not get handle from process: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubectl/exec_windows.go","lineNumber":69,"sourceCode":"\t\tBasicLimitInformation: windows.JOBOBJECT_BASIC_LIMIT_INFORMATION{\n\t\t\tLimitFlags: windows.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,\n\t\t},\n\t}\n\tif _, err := windows.SetInformationJobObject(\n\t\thandle,\n\t\twindows.JobObjectExtendedLimitInformation,\n\t\tuintptr(unsafe.Pointer(&info)),\n\t\tuint32(unsafe.Sizeof(info))); err != nil {\n\t\treturn fmt.Errorf(\"could not set information job object: %w\", err)\n\t}\n\n\tif err := c.Cmd.Start(); err != nil {\n\t\treturn fmt.Errorf(\"could not start the command: %w\", err)\n\t}\n\n\tprocessHandle, err := getHandleFromProcess(c.Process)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get handle from process: %w\", err)\n\t}\n\n\tif err := windows.AssignProcessToJobObject(handle, processHandle); err != nil {\n\t\treturn fmt.Errorf(\"could not assign job object: %w\", err)\n\t}\n\n\tc.handle = handle\n\tgo func() {\n\t\t<-c.ctx.Done()\n\t\tc.Terminate()\n\t}()\n\n\treturn nil\n}\n\nfunc getHandleFromProcess(p *os.Process) (windows.Handle, error) {\n\t// os.Process contains an unexported processHandle struct, which contains\n\t// a `handle uintptr` field.","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubectl/exec_windows.go#L51-L87","documentation":"After the process starts, Start obtains a Win32 process handle (getHandleFromProcess on c.Process) needed to assign the process to the job object; this error wraps a handle-acquisition failure. Without the handle, the process cannot be attached to the kill-on-close job group.","triggerScenarios":"getHandleFromProcess fails because OpenProcess on the just-started process returns an error — the process exited immediately, or access rights to open the handle were denied.","commonSituations":"The spawned binary crashes/exits instantly (race: handle opened after exit), restricted token lacking PROCESS_ALL_ACCESS / needed rights, security software terminating the child at spawn.","solutions":["Check why the child exits immediately: run it manually; fix its crash/exit (bad args, missing config)","Inspect the wrapped %w Win32 error for access-denied and run with sufficient privileges","Check antivirus/EDR logs for child-process termination","Retry; if the race on immediate exit is the cause, add retry or detect child exit first"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := c.Start(); err != nil {\n    if strings.Contains(err.Error(), \"could not get handle from process\") {\n        return fmt.Errorf(\"child exited before handle acquisition (%w); run child manually to see its crash\", err)\n    }\n    return err\n}","preventionTips":["Validate the child command runs successfully standalone before embedding it","Ensure the process token has rights to open child process handles","Check EDR/AV policies that terminate child processes at spawn","Log child stderr so immediate exits are diagnosable"],"tags":["windows","process","handle"],"backgroundTag":"process-handle-open-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}