{"record":{"id":"410834969a2c5f47","repo":"podman-container-tools/podman","slug":"fork-m","errorCode":null,"errorMessage":"fork: %m","messagePattern":"fork: %m","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libpod/container_top_linux.c","lineNumber":65,"sourceCode":"  this is done so we can mount proc after the fork because the pid namespace is\n  only active after spawning children.\n*/\nvoid\nfork_exec_ps ()\n{\n  int r, status = 0;\n  pid_t pid;\n\n  if (argv == NULL)\n    {\n      fprintf (stderr, \"argv not initialized\");\n      exit (special_exit_code);\n    }\n\n  pid = fork ();\n  if (pid < 0)\n    {\n      fprintf (stderr, \"fork: %m\");\n      exit (special_exit_code);\n    }\n  if (pid == 0)\n    {\n      r = mount (\"proc\", \"/proc\", \"proc\", 0, NULL);\n      if (r < 0)\n        {\n          fprintf (stderr, \"mount proc: %m\");\n          exit (special_exit_code);\n        }\n      if (join_userns)\n        {\n          // join the userns to make sure uid mapping match\n          // we are already part of the pidns so so pid 1 is the main container process\n          r = open (\"/proc/1/ns/user\", O_CLOEXEC | O_RDONLY);\n          if (r < 0)\n            {\n              fprintf (stderr, \"open /proc/1/ns/user: %m\");","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/libpod/container_top_linux.c#L47-L83","documentation":"fork() failed inside fork_exec_ps(), the cgo helper that runs ps in the container's PID namespace for 'podman top'. %m expands to strerror(errno): typically EAGAIN (RLIMIT_NPROC, cgroup pids.max, or kernel threads-max exceeded) or ENOMEM. The helper exits 255 (special_exit_code), so the user sees this message and a 255 exit from the podman top reexec.","triggerScenarios":"'podman top CTOR' when the podman process cannot create one more process: container's pids cgroup at its --pids-limit, user's ulimit -u exhausted (rootless), or system-wide threads-max reached. EAGAIN is the common errno.","commonSituations":"Containers run with a very low --pids-limit whose podman top helper shares the limit context; fork-bomb protection (kernel.threads-max, systemd TasksMax) tripping; zombie/process leakage from a leaking workload.","solutions":["Raise the pids limit: run the container with a larger --pids-limit (or remove it)","Check and raise ulimit -u (RLIMIT_NPROC) for the user running podman, and systemd TasksMax for rootless sessions","Clean up leaked processes/zombies in the container or session, then retry podman top","Verify with: cat /sys/fs/cgroup/pids.max and ps -eLf | wc -l"],"exampleFix":"# before\npodman run --pids-limit 10 -d quay.io/libpod/alpine top -d\n\n# after\npodman run --pids-limit 200 -d quay.io/libpod/alpine top -d","handlingStrategy":"retry","validationCode":"# Pre-flight: is there headroom to fork one more process?\n#!/bin/sh\npidmax=$(cat /sys/fs/cgroup/pids.max 2>/dev/null || cat /sys/fs/cgroup/pids/pids.max 2>/dev/null || echo max)\n[ \"$pidmax\" = max ] || {\n  cur=$(cat /sys/fs/cgroup/pids.current 2>/dev/null || cat /sys/fs/cgroup/pids/pids.current)\n  [ \"$cur\" -lt $((pidmax - 5)) ] || { echo \"pids cgroup nearly full: $cur/$pidmax\" >&2; exit 1; }\n}\nnproc_lim=$(ulimit -u)\n[ \"$nproc_lim\" = unlimited ] || [ \"$(ps -o nlwp= -p $$ 2>/dev/null || echo 0)\" -lt \"$nproc_lim\" ] || true\nexec podman top \"$@\"","typeGuard":null,"tryCatchPattern":"#!/bin/sh\n# EAGAIN (Resource temporarily unavailable) from fork is retryable\ni=0\nwhile ! out=$(podman top \"$ctr\" 2>&1); do\n  case \"$out\" in *fork:*Resource*temporarily*unavailable*|*'fork: EAGAIN'*)\n      i=$((i+1)); [ $i -le 3 ] || { echo \"$out\" >&2; exit 1; }\n      sleep 2;;\n    *) echo \"$out\" >&2; exit 1;;\n  esac\ndone\nprintf '%s\\n' \"$out\"","preventionTips":["Size --pids-limit with headroom for podman's own helper processes, not just the workload","For rootless, ensure the user's ulimit -u and the systemd user slice TasksMax leave slack","Monitor pids.current/pids.max in the podman process's cgroup; near-full means top (and exec) will start failing"],"tags":["podman-top","fork","process-limits"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}