Skip to content
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

toolbox run command isn't terminated properly when terminal emulator is exited #1157

Closed
ghost opened this issue Nov 15, 2022 · 3 comments · May be fixed by #1207
Closed

toolbox run command isn't terminated properly when terminal emulator is exited #1157

ghost opened this issue Nov 15, 2022 · 3 comments · May be fixed by #1207
Labels
1. Bug Something isn't working

Comments

@ghost
Copy link

ghost commented Nov 15, 2022

Describe the bug

toolbox run command isn't terminated properly when terminal emulator is exited, causing processes to linger around without user's awareness.

Steps how to reproduce the behaviour

  1. Open System Monitor / Task Manager equivilent in your desktop environment
  2. Search for sleep
  3. Execute the following command in a terminal emulator (GNOME Terminal):
toolbox run sleep 30
  1. Before sleep runs out of time, try to close the terminal emulator
  2. It'll prompt for something like this:

image

Insist closing it by pressing Close Terminal.

Expected behaviour

sleep process is terminated.

Actual behaviour

sleep keeps lingering around.

Output of toolbox --version (v0.0.90+)

toolbox version 0.0.99.3

Toolbox package info (rpm -q toolbox)

toolbox-0.0.99.3-6.fc36.x86_64

Output of podman version

Client:       Podman Engine
Version:      4.2.1
API Version:  4.2.1
Go Version:   go1.18.5
Built:        Thu Sep  8 03:58:19 2022
OS/Arch:      linux/amd64

Podman package info (rpm -q podman)

podman-4.2.1-2.fc36.x86_64

Info about your OS

Fedora Silverblue 36

Additional context

This is a screenshot which represent the issue better:

image

If I try to close the terminal emulator, it'll prompt the following:

image

If I press "Close Terminal", sh, toolbox and podman (which runs exec command) will be terminated because they're child process of the vte session.

However, notice the conmon and its child process sleep aren't part of gnome-terminal-server. When sh is terminated, podman (exec command) will be terminated but the corresponding conmon process will be kept intact. As a result, sleep 30 isn't terminated properly.

And sleep 30 is only used for demonstration. In reality one could run something resource intensive, and then close the terminal emulator not knowing they're lingering in the background.

Source: #1204

@ghost ghost added the 1. Bug Something isn't working label Nov 15, 2022
halfline added a commit to halfline/toolbox that referenced this issue Dec 22, 2022
Right now "toolbox enter" creates a container on the fly, but
then lets it linger after the foreground toolbox process is
killed (for instance, from a terminal hangup).

Not killing the underlying container has the negative side effect of
stalling shutdown if a toolbox shell is running.

This commit addresses that problem by detecting when the toolbox process
is signaled, and then in response, kills off the entire cgroup associated
with the underlying container.

Closes containers#1157
halfline added a commit to halfline/toolbox that referenced this issue Dec 22, 2022
Right now "toolbox enter" creates a container on the fly, but
then lets it linger after the foreground toolbox process is
killed (for instance, from a terminal hangup).

Not killing the underlying container has the negative side effect of
stalling shutdown if a toolbox shell is running.

This commit addresses that problem by detecting when the toolbox process
is signaled, and then in response, kills off the entire cgroup associated
with the underlying container.

Closes containers#1157

Signed-off-by: Ray Strode <[email protected]>
halfline added a commit to halfline/toolbox that referenced this issue Dec 22, 2022
Right now "toolbox enter" creates a container on the fly, but
then lets it linger after the foreground toolbox process is
killed (for instance, from a terminal hangup).

Not killing the underlying container has the negative side effect of
stalling shutdown if a toolbox shell is running.

This commit addresses that problem by detecting when the toolbox process
is signaled, and then in response, kills off the entire cgroup associated
with the underlying container.

Closes containers#1157

Signed-off-by: Ray Strode <[email protected]>
@debarshiray
Copy link
Member

Duplicate of #1204

@debarshiray debarshiray marked this as a duplicate of #1204 Sep 30, 2023
@debarshiray
Copy link
Member

I know you had originally filed #1204 against Podman, but for some reason @rhatdan moved it to Toolbx, and he hasn't responded since. So, for all practical purposes, we can treat them as duplicates.

@debarshiray
Copy link
Member

Thanks for playing with Toolbx and contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant