{"record":{"id":"d3ab12355a2371e1","repo":"argoproj/argo-workflows","slug":"failed-to-open-process-w","errorCode":null,"errorMessage":"failed to open process: %w","messagePattern":"failed to open process: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/executor/osspecific/signal_windows.go","lineNumber":69,"sourceCode":"}\n\nfunc Wait(process *os.Process) error {\n\tstat, err := process.Wait()\n\tif stat.ExitCode() != 0 {\n\t\treturn errors.NewExitErr(stat.ExitCode())\n\t}\n\treturn err\n}\n\n// signalProcess sends the specified signal to a process.\n//\n// Code +/- copied from: https://github.com/microsoft/hcsshim/blob/1d69a9c658655b77dd4e5275bff99caad6b38416/internal/jobcontainers/process.go#L251\n// License: MIT\n// Author: Microsoft\nfunc signalProcess(pid uint32, signal int) error {\n\thProc, err := windows.OpenProcess(windows.PROCESS_TERMINATE, true, pid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open process: %w\", err)\n\t}\n\tdefer func() {\n\t\t_ = windows.Close(hProc)\n\t}()\n\n\tif err := procCtrlRoutine.Find(); err != nil {\n\t\treturn fmt.Errorf(\"failed to load CtrlRoutine: %w\", err)\n\t}\n\n\tthreadHandle, err := createRemoteThread(hProc, nil, 0, procCtrlRoutine.Addr(), uintptr(signal), 0, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open remote thread in target process %d: %w\", pid, err)\n\t}\n\tdefer func() {\n\t\t_ = windows.Close(windows.Handle(threadHandle))\n\t}()\n\treturn nil\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/executor/osspecific/signal_windows.go#L51-L87","documentation":"Windows implementation of signalProcess: windows.OpenProcess(PROCESS_TERMINATE, ...) failed, so the executor could not get a handle to the target process in order to terminate/signal it. The underlying Windows error is wrapped — most commonly ERROR_ACCESS_DENIED (5) if the argoexec process lacks rights on the target, or the process already exited.","triggerScenarios":"Kill() calls signalProcess(pid, sig) and the OS refuses the OpenProcess call — bad/already-reaped pid, insufficient privileges, or protected process.","commonSituations":"Target container process already exited (stale pid) so OpenProcess returns ERROR_INVALID_PARAMETER; argoexec service account lacking PROCESS_TERMINATE rights on the job-container process; Windows job-object/container hardening blocking cross-process access.","solutions":["Read the wrapped errno: ERROR_ACCESS_DENIED → permissions; ERROR_INVALID_PARAMETER → pid no longer exists","Treat 'process not found' as success (the kill goal was already met) — check if the pid belonged to an already-completed main container","Run argoexec with sufficient privileges in the container (job-container process access)","Retry briefly before failing — there is an inherent race between reading the pid and the process exiting"],"exampleFix":"// caller-side tolerance\nif err := osspecific.Kill(pid); err != nil {\n    if !strings.Contains(err.Error(), \"The parameter is incorrect\") { // already exited\n        return err\n    }\n}","handlingStrategy":"try-catch","validationCode":"// check the process exists before signaling\nif h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, pid); err != nil {\n    // already gone — skip kill\n} else { windows.Close(h) }","typeGuard":null,"tryCatchPattern":"if err := osspecific.Kill(pid); err != nil {\n    if strings.Contains(err.Error(), \"The parameter is incorrect\") {\n        // process already exited; treat as success\n    } else {\n        return err\n    }\n}","preventionTips":["Handle stale pids gracefully — race between pid capture and process exit is inherent","Run argoexec with privileges granting PROCESS_TERMINATE on job-container processes","Log and include the wrapped Windows errno for diagnosis"],"tags":["windows","signals","process","executor"],"backgroundTag":"open-process-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}