Skip to content

Commit 832522a

Browse files
committed
docs: add warning about orphaned child processes with --pid host
Add documentation and warning about a limitation of --pid host mode: orphaned child processes may remain after container stop/rm. This is a known podman limitation (containers/podman#11888), not something introduced by our workaround. The workaround only kills the init process; child processes that daemonized or backgrounded will persist. Changes: - Add warning in distrobox-create for rootless podman without --unshare-process - Document the limitation in distrobox-stop and distrobox-rm comments - Recommend --unshare-process for full process cleanup Signed-off-by: xz-dev <xiangzhedev@gmail.com>
1 parent 1a7f77f commit 832522a

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

distrobox-create

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,13 @@ generate_create_command()
692692
if [ "${unshare_process}" -eq 0 ]; then
693693
result_command="${result_command}
694694
--pid host"
695+
# Warn about --pid host limitation in rootless podman mode.
696+
# See: https://github.com/containers/podman/issues/11888
697+
if [ "${rootful}" -eq 0 ] && echo "${container_manager}" | grep -q "podman"; then
698+
printf >&2 "Warning: using --pid host with rootless podman.\n"
699+
printf >&2 "Warning: orphaned child processes may remain after container stop.\n"
700+
printf >&2 "Warning: consider using --unshare-process for full process cleanup.\n"
701+
fi
695702
fi
696703
# Mount useful stuff inside the container.
697704
# We also mount host's root filesystem to /run/host, to be able to syphon

distrobox-rm

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,12 @@ delete_container()
401401
# This sends the signal directly to the container's init process PID, bypassing
402402
# the cgroup lookup issue.
403403
#
404-
# Note: distrobox-rm does not call distrobox-stop (by design, it relies on
405-
# "podman rm --force" to handle stopping). A similar fix exists in distrobox-stop
406-
# for the "distrobox stop" command.
407-
if [ "${container_status}" = "running" ] && [ "${rootful}" -eq 0 ]; then
408-
case "${container_manager}" in
409-
*podman*)
410-
${container_manager} kill "${container_name}" > /dev/null 2>&1 || :
411-
;;
412-
esac
404+
# Note: This only kills the init process, not any orphaned child processes - this is
405+
# a limitation of --pid host mode (see https://github.com/containers/podman/issues/11888).
406+
# To ensure all processes are cleaned up, use --unshare-process when creating the container.
407+
# distrobox-rm does not call distrobox-stop by design; a similar fix exists there.
408+
if [ "${container_status}" = "running" ] && [ "${rootful}" -eq 0 ] && echo "${container_manager}" | grep -q "podman"; then
409+
${container_manager} kill "${container_name}" > /dev/null 2>&1 || :
413410
fi
414411
# shellcheck disable=SC2086,SC2248
415412
${container_manager} rm ${force_flag} --volumes "${container_name}"

distrobox-stop

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ case "${response}" in
295295
# In rootless mode, podman stop uses "crun kill --all" which fails when
296296
# cgroup-path is empty (which happens with --pid host, the distrobox default).
297297
# Using "kill" first (which uses "crun kill" without --all) ensures the
298-
# container is terminated.
299-
if [ "${rootful}" -eq 0 ]; then
300-
case "${container_manager}" in
301-
*podman*)
302-
${container_manager} kill "${container_name}" 2> /dev/null || :
303-
;;
304-
esac
298+
# container's init process is terminated.
299+
#
300+
# Note: This only kills the init process, not any orphaned child processes - this is
301+
# a limitation of --pid host mode (see https://github.com/containers/podman/issues/11888).
302+
# To ensure all processes are cleaned up, use --unshare-process when creating the container.
303+
if [ "${rootful}" -eq 0 ] && echo "${container_manager}" | grep -q "podman"; then
304+
${container_manager} kill "${container_name}" 2> /dev/null || :
305305
fi
306306
${container_manager} stop "${container_name}" 2> /dev/null || :
307307
done

0 commit comments

Comments
 (0)