{"record":{"id":"da6b0343ad40085c","repo":"hashicorp/nomad","slug":"executor-failed-to-find-process-v","errorCode":null,"errorMessage":"executor failed to find process: %v","messagePattern":"executor failed to find process: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor.go","lineNumber":633,"sourceCode":"// kills the user process.\nfunc (e *UniversalExecutor) Shutdown(signal string, grace time.Duration) error {\n\te.logger.Debug(\"shutdown requested\", \"signal\", signal, \"grace_period_ms\", grace.Round(time.Millisecond))\n\tvar merr multierror.Error\n\n\t// If the executor did not launch a process, return.\n\tif e.command == nil {\n\t\treturn nil\n\t}\n\n\t// If there is no process we can't shutdown\n\tif e.childCmd.Process == nil {\n\t\te.logger.Warn(\"failed to shutdown due to missing process\", \"error\", \"no process found\")\n\t\treturn fmt.Errorf(\"executor failed to shutdown error: no process found\")\n\t}\n\n\tproc, err := os.FindProcess(e.childCmd.Process.Pid)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"executor failed to find process: %v\", err)\n\t\te.logger.Warn(\"failed to shutdown due to inability to find process\", \"pid\", e.childCmd.Process.Pid, \"error\", err)\n\t\treturn err\n\t}\n\n\t// If grace is 0 then skip shutdown logic\n\tif grace > 0 {\n\t\t// Default signal to SIGINT if not set\n\t\tif signal == \"\" {\n\t\t\tsignal = \"SIGINT\"\n\t\t}\n\n\t\tsig, ok := signals.SignalLookup[signal]\n\t\tif !ok {\n\t\t\terr = fmt.Errorf(\"error unknown signal given for shutdown: %s\", signal)\n\t\t\te.logger.Warn(\"failed to shutdown\", \"error\", err)\n\t\t\treturn err\n\t\t}\n","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor.go#L615-L651","documentation":"Wraps an error from os.FindProcess(e.childCmd.Process.Pid) during Shutdown. On Unix FindProcess rarely fails (it just returns a Process handle), so this usually indicates a system-level failure resolving the PID; on Windows it means the process no longer exists. The PID from the child command could not be resolved for signaling.","triggerScenarios":"Calling Shutdown when the child process already exited and was reaped (Windows) or the OS refused the PID lookup (resource issues, PID namespace mismatch).","commonSituations":"Task exited just before shutdown; container/PID-namespace boundary so the PID is invisible; Windows host where the process handle is gone.","solutions":["Check the wrapped inner error (%v) for the OS-level cause","If the process already exited, treat shutdown as complete and proceed to cleanup","Verify client and task share the expected PID namespace (avoid hiding task PIDs from the client)","Retry Shutdown once; transient PID-resolution failures are rare"],"exampleFix":"// before\nif err := exec.Shutdown(); err != nil {\n    return err\n}\n// after\nif err := exec.Shutdown(); err != nil {\n    if strings.Contains(err.Error(), \"failed to find process\") {\n        logger.Warn(\"task process already gone; skipping graceful shutdown\")\n        return nil\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// Verify PID is visible before shutdown\nif pid > 0 {\n    if _, err := os.FindProcess(pid); err != nil {\n        return nil // process already gone\n    }\n    // On unix, optionally check /proc/<pid> existence\n    if _, err := os.Stat(fmt.Sprintf(\"/proc/%d\", pid)); os.IsNotExist(err) {\n        return nil\n    }\n}","typeGuard":"func pidAlive(pid int) bool {\n    if pid <= 0 { return false }\n    proc, err := os.FindProcess(pid)\n    if err != nil { return false }\n    return proc.Signal(syscall.Signal(0)) == nil\n}","tryCatchPattern":"if err := exec.Shutdown(); err != nil {\n    if strings.Contains(err.Error(), \"failed to find process\") {\n        log.Info(\"process already gone; skipping graceful shutdown\")\n        return nil\n    }\n    return err\n}","preventionTips":["Check process liveness (signal 0) before shutdown","Avoid PID-namespace configurations that hide task PIDs from the client","Handle the already-exited race as a success case, not an error"],"tags":["process","shutdown","executor"],"backgroundTag":"process-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}