-
Notifications
You must be signed in to change notification settings - Fork 224
Optionally make exec session terminate with parent #1204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's more accurate to say that we can't make them not terminate when the container exits. The kernel enforces the rule that any PID namespace will kill every process in the namespace if PID 1 in the namespace dies; Podman will take down PID 1, guaranteeing that the kernel will unwind the rest of the namespace. For containers without a PID namespace, it's a bit trickier, but we do have an accurate list of processes in the container, which we then individually kill as part of stopping the container. In short, I strongly doubt your Podman reproducer actually does what you think it does; the kernel simply won't allow that to happen. |
Sorry if i didn't explain it deeper. I'm not talking about the process being lingering when container is stopped, as this had never been the case, just as you said. With And the parent I'm talking isn't PID 1 of the container, but the This is a screenshot which represent the issue better: If I try to close the terminal emulator, it'll prompt the following: If I press "Close Terminal", However, notice the And This is probably only an issue for pet container usecase. The feature request, to be precise, is to add an optional flag that make the |
@mheon I think the request is basically to not double fork conmon and not let it create a new process group to keep it attached to the podman parent process. |
Yes. This would work as well. |
@Luap99 Don't know if that works. Conmon dying is only going to take out the first PID the exec session started; anything else it did, probably just reparents on top of PID 1 in the container. So we can definitely kill a single-process exec session, but a We don't really have a robust way of tracking what processes were spawned from an exec session right now. We'd basically have to walk the process tree in the container, which seems potentially racy. On CGv2, a child cgroup might be a solution? Just need to make sure it doesn't interfere with the container itself being stopped... |
I believe it walks the cgroup and kills all of the pids within the cgroup, or at least I remember this is what we wrote many years ago. |
I wonder if Toolbx could detect this scenario and explicitly terminate the process that it had launched inside the container. |
A friendly reminder that this issue had no activity for 30 days. |
This seems like more of an issue for toolbx rather then podman. |
Umm... it's not really clear to me what Toolbx could do here. Is there a recommended way to get to the process ID of the conmon process? |
I think it's good enough if conmon died and took out the first PID that the
... if this was a shell directly running on the host without involving any containers, the expectation is that closing the terminal emulator takes out the shell and anything that's willing to die with it. If someone started a process in the background (say, |
@giuseppe ameliorated one problematic outcome of this - the processes inside the However, it's still worth trying to ensure that the processes inside the I have to say that I am a bit puzzled that the processes are outliving their controlling terminal. I know there's an inner nested terminal device for the container, but isn't it supposed to go away with the outer terminal? |
@mheon @rhatdan @Luap99 @giuseppe Could one of you please help answer this question? We are brainstorming various options at #1207 but it's not clear if it's possible for the Also, it's not clear to me why |
I wonder if it will be easier for you to just use the OCI runtime to do the exec. e.g. if you do Can you please play with it and see if "crun exec" does all you need? Adding it to Podman/conmon will be much more complicated, we will need to change the way conmon works to not perform a double fork. |
That said ref #1400 |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind feature
Description
Add a flag to
podman exec
to make exec session terminate with parent, similar to bubblewrap'sbwrap --die-with-parent
.Immutable distributions make use of
toolbox
/distrobox
to provide a mutable environment. A common use is to run commands directly within container (toolbox run [COMMAND]
/distrobox enter -- [COMMAND]
), since they use exec session, they have the same limitation of not terminating child-proceess when terminal emulator is closed.Steps to reproduce the issue:
Open System Monitor / Task Manager equivilent in your desktop environment, search for
sleep
Run the following command in your terminal emulator (either one will work):
podman:
toolbox:
distrobox:
Describe the results you received:
sleep 30
still runs within container.Describe the results you expected:
Nah, this is expected, hence this feature request.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info
:Click me
Package info (e.g. output of
rpm -q podman
orapt list podman
orbrew info podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Additional environment details (AWS, VirtualBox, physical, etc.):
Fedora Silverblue 36
The text was updated successfully, but these errors were encountered: