Skip to content

CLI processes started in distrobox/toolbox are not terminated correctly #533

Open
@1player

Description

I am aware that this is not a Silverblue-only issue, but it affects all users due to the heavy use of toolbox and the likes, and I'm at my wits ends to track this issue down, after opening bug reports on podman, distrobox, toolbox to no real concrete answer.

Steps to reproduce:

  • Enter a distrobox or toolbox container in a terminal emulator
  • Run a command (i.e. top)
  • Close the terminal emulator

Expected result

The command to be terminated after the window is closed.

Actual result

The process stays running in the background.

Discussion

There seems to be an issue with how podman, distrobox or toolbox are handling SIGHUP signals which should cause the shell and background processes to be terminated, but does not in practice. The result is any command left running in a toolbox keeps running until the system is rebooted.

On my Silverblue machine, in 48 hours of uptime I have accumulated 38 zsh processes that keep running in the background because they are not killed appropriately:

toolbox:~ % ps aux | grep zsh | wc -l 
38
toolbox:~ % ps aux | grep zsh | head  
sph         5447  0.0  0.0  11620  7836 pts/0    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        17014  0.0  0.0  11288  7464 pts/1    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        18317  0.0  0.0  11288  7640 pts/2    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        18711  0.0  0.0  11120  7316 pts/3    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        19027  0.0  0.0  11120  7396 pts/4    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        19668  0.0  0.0  11120  7316 pts/5    Ss   Feb08   0:00 /usr/bin/zsh -l
sph        19716  0.0  0.0 227848  8212 pts/6    Ss+  Feb08   0:00 /usr/bin/zsh
sph        25591  0.0  0.0  11468  7644 pts/7    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        27631  0.0  0.0  11428  7636 pts/8    Ss+  Feb08   0:00 /usr/bin/zsh -l
sph        28415  0.0  0.0  11292  7492 pts/9    Ss+  Feb08   0:00 /usr/bin/zsh -l

All these processes are connected to dead pseudo-terminals. This happens because I have configured my terminal emulator (Prompt) to automatically enter inside the container, which triggers this issue every single time I open a window. I expect everything to terminate when I close the terminal, but it does not happen.

The only workaround is to reboot the machine often to clean up what is effectively a memory leak.

As I said, this is not the appropriate place for this issue perhaps, but I would like to understand where even to start to track down this issue, and if it happens only in my machine -- because I can reproduce 100% of the time, whatever the shell, terminal emulator or DE. Given that Fedora Atomic distro workflows are centred around using containers for most of the work, having processes that are not terminated correctly is a major bug and an unnecessary leak of resources.

When I mentioned this behaviour on the podman tracker, I've been told it's not a podman issue, but a toolbox and distrobox one. toolbox and distrobox know it's an issue but there doesn't seem to be any movement on it whatsoever.

Related issues:

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingf39Related to Fedora 39f40Related to Fedora 40kinoiteAlso affect Fedora KinoiteupstreamIssue reported, fixed or related to upstream projects

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions