Skip to content

distrobox-enter should terminate child processes when the terminal is closed #966

Open
@1player

Description

A bit of a weird one... I've been trying to figure out why host-spawn, and its children, do not terminate on my machine when I close a terminal window (1player/host-spawn#27). In theory, when you close a terminal window, a SIGHUP is sent to the controlling process, so anything that was running is terminated cleanly, which is what everyone expects.

This doesn't happen with distrobox-enter. This script calls podman exec, which ignores SIGHUP (probably because it is/was originally intended to run containers in the background), so any process running inside the container is never terminated and runs indefinitely in the background.

Steps to reproduce

  • Enter a distrobox container in a terminal window
  • Run a long running process (sleep infinity)
  • Close the terminal window
  • Notice that the long running process is still running

Expected behaviour (how it works normally)

  • Open a terminal window on the host
  • Run a long running process (sleep infinity)
  • Close the terminal window
  • Notice that the long running process has been terminated

This discrepancy is because SIGHUP, sent by the kernel when the pty closes, so that the foreground process can terminate, is being ignored by podman exec. I'm unsure what's the best approach here.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwait-on-userwaiting for a reply

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions