{"record":{"id":"0a9ebfa5cdbb3987","repo":"hashicorp/nomad","slug":"executor-failed-to-shutdown-error-no-process-foun","errorCode":null,"errorMessage":"executor failed to shutdown error: no process found","messagePattern":"executor failed to shutdown error: no process found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"drivers/shared/executor/executor.go","lineNumber":628,"sourceCode":"\t// existing process (e.g. when killing a process group).\n\tnoSuchProcessErr = \"no such process\"\n)\n\n// Shutdown cleans up the alloc directory, destroys resource container and\n// 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 {","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor.go#L610-L646","documentation":"UniversalExecutor.Shutdown returns this when the executor's child command has no os.Process (childCmd.Process == nil), meaning the task process was never actually launched or the handle is stale. Nomad cannot signal or wait on a nonexistent process, so Shutdown fails rather than silently succeeding.","triggerScenarios":"Calling Shutdown on an executor whose Launch either failed before starting the process or was never called; racing Shutdown against a not-yet-started task; restoring a task handle where the process record was lost.","commonSituations":"Task recovery after client restart with a stale executor handle; shutdown called concurrently with a failed Launch; tests that construct an executor without launching a command.","solutions":["Ensure Launch succeeded (check its error) before calling Shutdown","Treat this as a no-op cleanup: the task is not running, so log and continue with task destruction","Check for races: synchronize Shutdown with task start, or recover the real PID via os.FindProcess if known"],"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(), \"no process found\") {\n        return nil // task never started; nothing to shut down\n    }\n    return err\n}","handlingStrategy":"try-catch","validationCode":"// Ensure the task is running before shutdown\nif !taskState.Running || taskState.Pid == 0 {\n    return nil // nothing to shut down\n}","typeGuard":"func executorHasProcess(p *os.Process) bool { return p != nil }","tryCatchPattern":"if err := exec.Shutdown(); err != nil {\n    if strings.Contains(err.Error(), \"no process found\") {\n        log.Warn(\"executor had no child process; treating as already stopped\")\n        return nil\n    }\n    return err\n}","preventionTips":["Always check Launch's error before lifecycle calls","Serialize start/stop operations on a task to avoid races","During task recovery, verify the PID is alive before signaling"],"tags":["executor","process-lifecycle","shutdown"],"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"}