Open hmkemppainen opened 1 year ago
Thanks for opening and the issue along with the reproducer, @hmkemppainen !
I am surprised this doesn't work but did not take a look at the code.
Cc: @mheon
The podman exec
is kind of like podman run
- it's just running the attach session associated with the exec'd process. The process in question has reparented on the container's PID1, it's associated with the container's cgroups, so once podman exec
has successfully started the process in the container it's no longer associated at all with the frontend beyond the conmon
process forwarding us the session's standard streams.
So this is basically what I'd expect. We do have additional primitives exposed via API for dealing with exec sessions, including the ability to kill running sessions, but we don't expose those via CLI, only the Docker-compat API.
A friendly reminder that this issue had no activity for 30 days.
Does podman exec handle SIGTERM in this case? IE does it kill the exec session?
No, we don't sig-proxy for exec.
That is unexpected from the User, At least this user.
Would you expect that SIGTERM would kill the whole exec session or just PID1?
Well, the first PID of the exec session, not PID1
Yes I think this would be the Human expectation. If I am running podman exec -ti qm top
and hit ^z I would expect that process to exit. It probably often does when the TTY Connection goes away, but forwarding the signal to process would help. I don't think we can guarantee that the processes exits, but well behaved ones should.
Issue Description
Processes started by
podman exec
(without--detach
) may be left running when the podman process is terminated.I don't know if this is a bug or a feature, but it can make it very difficult for the parent process to correctly manage its children and this can lead to annoying failure modes.
Steps to reproduce the issue
Steps to reproduce the issue:
use
podman run
to start a container running netcat:$ podman run --rm -i alpine nc -vnlkp 1234
use
podman exec
to start another netcat, connecting to the first one:$ podman exec -l -i nc -vn 127.0.0.1 1234
verify that you have four related processes:
kill the
podman exec
process:$ pkill -f podman\ exec
observe that
podman exec
is gone but the netcat is still running (and remains connected to the 1st netcat!)Describe the results you received
The process started under podman exec is still running, even though the podman process itself is gone.
This behavior will confuse parent processes that aren't nearly as interested in the lifetime of the podman glue as they are in the actual process they are trying to run inside the container. The usual way of killing or checking whether the interesting process is still alive doesn't work. Also using setsid() after fork & before execing podman and killing the process group doesn't kill the child, because it lives in yet another session.
Describe the results you expected
The child process should die along with podman exec.
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
No response
Additional information
No response