{"record":{"id":"233c346e86e2f17b","repo":"hashicorp/nomad","slug":"failed-to-create-stdout-v","errorCode":null,"errorMessage":"failed to create stdout: %v","messagePattern":"failed to create stdout: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor.go","lineNumber":269,"sourceCode":"// GetWriters returns the unexported io.WriteCloser for the stdout and stderr\n// handles. This is mainly used for unit testing purposes.\nfunc (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) {\n\treturn c.stdout, c.stderr\n}\n\ntype nopCloser struct {\n\tio.Writer\n}\n\nfunc (nopCloser) Close() error { return nil }\n\n// Stdout returns a writer for the configured file descriptor\nfunc (c *ExecCommand) Stdout() (io.WriteCloser, error) {\n\tif c.stdout == nil {\n\t\tif c.StdoutPath != \"\" && c.StdoutPath != os.DevNull {\n\t\t\tf, err := fifo.OpenWriter(c.StdoutPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to create stdout: %v\", err)\n\t\t\t}\n\t\t\tc.stdout = f\n\t\t} else {\n\t\t\tc.stdout = nopCloser{io.Discard}\n\t\t}\n\t}\n\treturn c.stdout, nil\n}\n\n// Stderr returns a writer for the configured file descriptor\nfunc (c *ExecCommand) Stderr() (io.WriteCloser, error) {\n\tif c.stderr == nil {\n\t\tif c.StderrPath != \"\" && c.StderrPath != os.DevNull {\n\t\t\tf, err := fifo.OpenWriter(c.StderrPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to create stderr: %v\", err)\n\t\t\t}\n\t\t\tc.stderr = f","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor.go#L251-L287","documentation":"ExecCommand.Stdout() lazily opens a FIFO writer at StdoutPath (when set and not /dev/null) so the parent can stream task stdout into the pipe. If fifo.OpenWriter fails (FIFO missing, not yet created, or permission denied) the error is wrapped with this message and Launch aborts.","triggerScenarios":"Launch() calls command.Stdout() and fifo.OpenWriter(c.StdoutPath) errors — the named pipe does not exist, was deleted, or the executor user lacks write permission.","commonSituations":"Task stdout fifo cleaned up too early by a prior failed launch, /tmp or data dir permissions changed, SELinux/apparmor blocking fifo open, exec task running as different UID than the client that created the fifo.","solutions":["Check the fifo path exists and is a pipe: ls -l /proc/<alloc-dir>/... ; restart the allocation to recreate it","Fix directory/ACL permissions so the executor user can open the fifo for writing","Review SELinux/apparmor denials in audit logs","Check the wrapped %v message: ENOENT means the fifo wasn't created; EACCES means permissions"],"exampleFix":"// before\n// drwx------ alloc-dir (executor user cannot reach fifo)\n// after\n// chown -R nomad:nomad alloc-dir && chmod 750 alloc-dir","handlingStrategy":"try-catch","validationCode":"func stdoutFifoReady(path string) error {\n  fi, err := os.Stat(path)\n  if err != nil { return fmt.Errorf(\"stdout fifo missing: %w\", err) }\n  if fi.Mode()&os.ModeNamedPipe == 0 { return fmt.Errorf(\"%s is not a fifo\", path) }\n  if fi.Mode().Perm()&0o200 == 0 { return fmt.Errorf(\"%s not writable\", path) }\n  return nil\n}","typeGuard":null,"tryCatchPattern":"if err := launchTask(); err != nil {\n  if strings.Contains(err.Error(), \"failed to create stdout\") {\n    log.Printf(\"stdout fifo broken, restarting alloc: %v\", err)\n    return restartAllocation()\n  }\n  return err\n}","preventionTips":["Ensure alloc dirs are owned by the nomad user","Avoid manual cleanup of alloc-dir fifos while tasks run","Check SELinux/apparmor policies for fifo denials","Keep client and plugin versions aligned"],"tags":["fifo","stdout","streaming","nomad-executor"],"backgroundTag":"fifo-open-failed","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"}