{"record":{"id":"7fc0f79b067aa0fb","repo":"Yeachan-Heo/oh-my-codex","slug":"omx-failed-to-reap-cleanup-failedpids-length","errorCode":null,"errorMessage":"[omx] Failed to reap ${cleanup.failedPids.length} orphaned OMX MCP process(es); continuing launch.","messagePattern":"\\[omx\\] Failed to reap (.+?) orphaned OMX MCP process\\(es\\); continuing launch\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli/index.ts","lineNumber":6198,"sourceCode":"      failures.push(error);\n    }\n  }\n  if (failures.length > 0) throw new AggregateError(failures, \"preLaunch setup finalization failed\");\n}\n\nasync function completePreLaunchSetup(\n  cwd: string,\n  sessionId: string,\n  notifyTempContract: NotifyTempContract | undefined,\n  codexHomeOverride: string | undefined,\n  enableNotifyFallbackAuthority: boolean,\n  worktreeDirty: boolean,\n): Promise<CompletionResult> {\n  const degraded: DegradedSetupOperation[] = [];\n  try {\n    const cleanup = await cleanupLaunchOrphanedMcpProcesses();\n    if (cleanup.terminatedCount > 0) console.log(`[omx] Reaped ${cleanup.terminatedCount} orphaned OMX MCP process(es) before launch.`);\n    if (cleanup.failedPids.length > 0) console.warn(`[omx] Failed to reap ${cleanup.failedPids.length} orphaned OMX MCP process(es); continuing launch.`);\n  } catch (error) {\n    degraded.push(\"orphan-reaping\");\n    logCliOperationFailure(error);\n  }\n  let instructions: string;\n  try {\n    const orchestrationMode = await resolveSessionOrchestrationMode(cwd, sessionId);\n    const overlay = await generateOverlay(cwd, sessionId, { orchestrationMode });\n    const launchAppendix = await readLaunchAppendInstructions();\n    const dirtyWorktreeGuidance = worktreeDirty\n      ? `\\n\\n## Session start: dirty worktree detected\\n\\nThis worktree has uncommitted changes that were present when the session launched.\\nBefore executing the requested task, resolve the dirty state first:\\n1. Review uncommitted changes with \\`git status\\` and \\`git diff\\`.\\n2. Commit, stash, or discard changes as appropriate.\\n3. Then proceed with the original task.`\n      : \"\";\n    instructions = launchAppendix.trim().length > 0 ? `${overlay}\\n\\n${launchAppendix}${dirtyWorktreeGuidance}` : `${overlay}${dirtyWorktreeGuidance}`;\n  } catch (error) {\n    return { kind: \"failure\", operation: \"overlay\", error };\n  }\n  try {\n    await writeSessionModelInstructionsFile(cwd, sessionId, instructions);","sourceCodeStart":6180,"sourceCodeEnd":6216,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L6180-L6216","documentation":"Before launch, the CLI attempts to terminate orphaned OMX MCP server processes left over from previous runs. Some of those processes (failedPids) could not be reaped — typically because they belong to another user, are zombies, or kill(2) failed. Launch continues anyway.","triggerScenarios":"cleanupLaunchOrphanedMcpProcesses() finds PIDs from a stale registry but process.kill fails for one or more (EPERM, invalid ownership) while terminatedCount or failedPids is non-empty.","commonSituations":"Running the CLI under a different user than the one that started earlier MCP processes; leftover processes after a crash or forced reboot of the session; containers sharing a PID namespace.","solutions":["Inspect and kill the leftover processes manually: `ps aux | grep -i omx` then `kill <pid>`","Ensure the same user account runs omx each time so it can signal its own orphans","Clean stale PID registry files under the omx state directory"],"exampleFix":"// before\n[omx] Failed to reap 2 orphaned OMX MCP process(es); continuing launch.\n\n// after\npkill -f 'omx.*mcp' ; omx launch","handlingStrategy":"fallback","validationCode":"import { existsSync, readFileSync } from 'node:fs';\nfunction staleOrphans(pidFile: string): number[] {\n  if (!existsSync(pidFile)) return [];\n  return readFileSync(pidFile,'utf8').split('\\n').map(Number).filter(Number.isInteger);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always shut down omx cleanly so MCP children are reaped","Run omx under a consistent user","Periodically clean stale PID registries in .omx/state"],"tags":["orphan-process","cleanup","mcp","permissions"],"backgroundTag":"process-cleanup-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}