On Mon, Jun 7, 2021 at 3:44 PM Hendrik Haddorp <hendrik.haddorp@gmx.net> wrote:
yeah, that's what I switch to now but as you can not trap SIGKILL this does not cover the case A gets killed that way.

Would using systemd be an option for you?  The Podman container could be moved into a systemd service (`podman-generate-systemd`).  If the unit sets PartOf=parent.service, it should be stopped if parent.service stops.  I did not test it but would assume that the container service should also stop if parent is killed.

Kind regards,
 Valentin
 
On 6/7/21 3:18 PM, Daniel Walsh wrote:
On 6/4/21 17:30, Hendrik Haddorp wrote:
Hi,

I have a process (A) that starts a podman container as a child process
(B). When A dies due to a crash or gets killed I want the container to
be killed as well. I tried to start B with all kinds of process
attributes, like Setsid = true, Setpgid = true, Pdeathsig = SIGKILL, but
B does not get killed and the container runs on. In fact I see that the
podman process B has another child process and B seems to get reparented
to a "systemd --user" process when A dies.

How can I make sure the podman container dies when the parent process dies?
This is on Linux and rootless.

thanks,
Hendrik
_______________________________________________
Podman mailing list -- podman@lists.podman.io
To unsubscribe send an email to podman-leave@lists.podman.io

You could trap the exit code and cause it to send a stop signal to podman.


trap "podman stop --timeout 0 CTRID" EXIT

_______________________________________________
Podman mailing list -- podman@lists.podman.io
To unsubscribe send an email to podman-leave@lists.podman.io

_______________________________________________
Podman mailing list -- podman@lists.podman.io
To unsubscribe send an email to podman-leave@lists.podman.io