{"record":{"id":"25b3d32f9c356ace","repo":"chenhg5/cc-connect","slug":"runtime-config-stdin-pipe-w","errorCode":null,"errorMessage":"runtime config stdin pipe: %w","messagePattern":"runtime config stdin pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/codex/session.go","lineNumber":669,"sourceCode":"func codexToolSuccess(status string, exitCode *int) bool {\n\ts := strings.ToLower(strings.TrimSpace(status))\n\tif exitCode != nil {\n\t\treturn *exitCode == 0\n\t}\n\treturn s == \"completed\" || s == \"success\" || s == \"succeeded\" || s == \"ok\"\n}\n\nfunc loadCodexRuntimeConfig(ctx context.Context, workDir string, extraEnv []string) (string, string, error) {\n\tcmd := exec.CommandContext(ctx, \"codex\", \"app-server\")\n\tcmd.Dir = workDir\n\tprepareCmdForKill(cmd)\n\tif len(extraEnv) > 0 {\n\t\tcmd.Env = core.MergeEnv(os.Environ(), extraEnv)\n\t}\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"runtime config stdin pipe: %w\", err)\n\t}\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"runtime config stdout pipe: %w\", err)\n\t}\n\tvar stderr bytes.Buffer\n\tcmd.Stderr = &stderr\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"runtime config start app-server: %w\", err)\n\t}\n\tdefer func() {\n\t\t_ = stdin.Close()\n\t\tif cmd.Process != nil {\n\t\t\t_ = cmd.Process.Kill()\n\t\t}\n\t\t_ = cmd.Wait()\n\t}()","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/codex/session.go#L651-L687","documentation":"loadCodexRuntimeConfig spawns the codex app-server to query runtime configuration and failed while creating the child process's stdin pipe via cmd.StdinPipe(). The os/exec pipe factory returns an error only when the OS denies pipe creation or the process is in an invalid state, so this almost always indicates OS-level resource exhaustion or misuse of the exec.Cmd.","triggerScenarios":"cmd.StdinPipe() returns a non-nil error inside loadCodexRuntimeConfig, immediately aborting runtime config retrieval with the wrapped error.","commonSituations":"File-descriptor exhaustion (too many open files / child processes leaked); running under a sandbox or container with a very low RLIMIT_NOFILE; hitting the process/thread limit.","solutions":["Check open file-descriptor usage (`ulimit -n`, `lsof -p <pid>`) and raise RLIMIT_NOFILE if it is exhausted.","Look for leaked codex app-server child processes (`ps aux | grep codex`) and kill them; ensure sessions are stopped properly so pipes are released.","Retry the operation once descriptors are freed — pipe creation is transient-conditional.","If running in a restricted container, raise the nofile limit in the container/daemon configuration."],"exampleFix":"// before: ulimit -n 256 (macOS default) exhausted by leaked app-server processes\n// after: raise the soft limit before launching the daemon\nulimit -n 10240","handlingStrategy":"retry","validationCode":"// check descriptor headroom before spawning probes\nvar lim syscall.Rlimit\nsyscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)\nif lim.Cur < 4096 { // headroom for pipes\n    lim.Cur = 65536\n    syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)\n}","typeGuard":null,"tryCatchPattern":"cfg, _, err := loadCodexRuntimeConfig(ctx, ...)\nif err != nil && strings.Contains(err.Error(), \"stdin pipe\") {\n    // transient: wait briefly and retry once after descriptors free\n    time.Sleep(500 * time.Millisecond)\n    cfg, _, err = loadCodexRuntimeConfig(ctx, ...)\n}","preventionTips":["Raise RLIMIT_NOFILE for the daemon (systemd LimitNOFILE, launchd hard limits)","Ensure sessions are stopped so child processes and their pipes are released","Monitor open FD counts and leak child processes with lsof","Avoid unbounded concurrent agent-session creation"],"tags":["codex","os-exec","pipe","file-descriptors"],"backgroundTag":"pipe-creation-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}