{"record":{"id":"d116ac680269a01b","repo":"podman-container-tools/podman","slug":"cannot-save-namespace-handles-m","errorCode":null,"errorMessage":"cannot save namespace handles: %m\n","messagePattern":"cannot save namespace handles: %m\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":1249,"sourceCode":"      fprintf (stderr, \"cannot chdir to %s: %m\\n\", cwd);\n      _exit (EXIT_FAILURE);\n    }\n\n  if (state_dir && state_dir[0] != '\\0')\n    {\n      /* Try to use namespace file handles instead of a pause process.  */\n      if (get_and_save_ns_handles_with_lock (state_dir) < 0)\n        {\n          /* Fall back to pause process only if kernel doesn't support nsfs handles,\n             if they are blocked (e.g. seccomp), or if the state directory doesn't exist yet.  */\n          if (errno == EOPNOTSUPP || errno == EPERM || errno == ENOSYS || errno == ENOENT)\n            {\n              if (create_pause_process (state_dir, argv) < 0)\n                _exit (EXIT_FAILURE);\n            }\n          else\n            {\n              fprintf (stderr, \"cannot save namespace handles: %m\\n\");\n              _exit (EXIT_FAILURE);\n            }\n        }\n    }\n  if (sigprocmask (SIG_SETMASK, &oldsigset, NULL) < 0)\n    {\n      fprintf (stderr, \"cannot block signals: %m\\n\");\n      _exit (EXIT_FAILURE);\n    }\n\n  execvp (\"/proc/self/exe\", argv);\n  fprintf (stderr, \"failed to reexec: %m\\n\");\n\n  _exit (EXIT_FAILURE);\n}\n\nstatic void\ncheck_proc_sys_userns_file (const char *path)","sourceCodeStart":1231,"sourceCodeEnd":1267,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L1231-L1267","documentation":"In the reexec_userns_join child (same block exists in reexec_in_user_namespace), get_and_save_ns_handles_with_lock(state_dir) failed — it creates/locks state_dir/ns_handles, gets nsfs file handles for the user+mount namespaces and saves them atomically — AND errno was NOT one of the tolerated fallback values (EOPNOTSUPP, EPERM, ENOSYS, ENOENT). Because the failure is 'unexpected', podman does not fall back to the pause process and _exit(EXIT_FAILURE)s. Real errnos here: ENOSPC/EIO writing the ns_handles file, EACCES/EROFS on the state dir, ENAMETOOLONG, lock-acquisition failures.","triggerScenarios":"PODMAN_NO_PAUSE_PROCESS=1 is set (ns-handles path active) and the state dir is unwritable, full, read-only, or its path exceeds PATH_MAX; corruption on the filesystem holding state_dir/ns_handles; flock contention failure inside acquire_ns_handles_lock.","commonSituations":"Disk-full or quota-exceeded home directories; state dir owned by another uid after uid changes; state dir on a read-only or failing mount; very long XDG paths.","solutions":["Fix the state dir: ls -ld \"$HOME/.local/share/containers\" (and $XDG_RUNTIME_DIR/containers) — it must be owned by you and writable; df -h to confirm space","Unset PODMAN_NO_PAUSE_PROCESS (or set it to 0) so rootless podman uses the pause-process fallback instead of ns handles, which does not hit this hard failure","Shorten the state dir path if it approaches PATH_MAX","Clear a corrupt ns_handles file: rm \"$state_dir/ns_handles\" and retry"],"exampleFix":"# before: ns-handles path fails hard\nexport PODMAN_NO_PAUSE_PROCESS=1\npodman system service\n\n# after: fall back to the pause process\nunset PODMAN_NO_PAUSE_PROCESS   # default is the pause process\npodman system service","handlingStrategy":"fallback","validationCode":"d=\"$HOME/.local/share/containers\"\n[ -d \"$d\" ] && [ -w \"$d\" ] || { echo \"state dir missing/not writable: $d\"; exit 1; }\ndf --output=pcent \"$d\" | tail -1   # leave headroom; ns_handles writes fail hard on ENOSPC","typeGuard":null,"tryCatchPattern":"# when ns-handle persistence keeps failing, switch to the pause-process mode\nif ! podman info >/dev/null 2>&1; then\n  unset PODMAN_NO_PAUSE_PROCESS   # pause process is the default fallback\n  podman info\nfi","preventionTips":["Keep the rootless state dir owned, writable, and with free space; monitor it like any database volume","Default to unset PODMAN_NO_PAUSE_PROCESS unless you specifically need nsfs handles","Keep state dir paths well under PATH_MAX; avoid deeply nested XDG overrides"],"tags":["podman","rootless","ns-handles","state-dir","pause-process"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}