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

Unable to easily stop an interactive podman container (keyboard) #10469

Closed
ssbarnea opened this issue May 26, 2021 · 11 comments
Closed

Unable to easily stop an interactive podman container (keyboard) #10469

ssbarnea opened this issue May 26, 2021 · 11 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@ssbarnea
Copy link
Collaborator

When running an interactive process like podman run --systemd=always -it fauust/docker-systemd:debian-10 you endup with an app that seems to not be responsive to any standard stop/kill signals.

  • Ctrl-C no effect
  • Ctr-D no effect
  • Ctrl-\ no effect
  • Magic key combination that appears to work Ctrl-P Ctrl-Q, but clearly that magic combination is not advertised by the application when it starts.

Ideally Ctrl-D and Ctrl-C should just work but if there is a technical reason why this cannot be fixed we should at least assure that podman does advertise on stderr the magic key combinations needed.

Reproduced on:

  • podman version 3.1.2 on macos (remoting)
  • poadman version 3.1.2 on fedora 34

Related #4397

@ssbarnea ssbarnea changed the title Unable to easily stop an interactive podman container (macos) Unable to easily stop an interactive podman container (keyboard) May 26, 2021
@fauust
Copy link

fauust commented May 26, 2021

Indeed, I can confirm this. Another workaround is to stop/kill the container from another terminal (but this is clearly not very friendly).

Reproduced on:

  • podman version 3.0.1 (Debian Bullseye);
  • podman version 3.0.0 (Debian Buster).

@ssbarnea ssbarnea added the kind/bug Categorizes issue or PR as related to a bug. label May 26, 2021
@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

Systemd always changes the Stop character to something only systemd understands, and you can not generate that at the keyboard.

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

man podman run
...
--systemd=true|false|always
...
It will also set the default stop signal to SIGRTMIN+3.

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

The issue is that systemd ignores all of these control chars.

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

@mheon Could we theoretically translate the ^c from the TTY to the stop signal of the container when Podman is attached. But even if we could this might not be what the user expects.

@mheon
Copy link
Member

mheon commented May 26, 2021

@rhatdan That seems dangerous. What if the user actually wanted to send SIGTERM?

I think this is a unique case, and needs to be treated as one. Systemd only wants to stop if given a very specific and very unusual signal - SIGINT and SIGTERM as you might get with kill/Control-C are not sufficient. I think we have to respect systemd's wishes here.

@rhatdan rhatdan closed this as completed May 26, 2021
@ssbarnea
Copy link
Collaborator Author

While I can understand @mheon concerns about changing default behavior, I do not see why we should not improve the user experience and log something like below when running with --systemd=always -it options:

To stop current interactive systemd container press ^P^Q as normal keyboard signals are ignored.

Later we could even add another opt-in (configurable option) that translates a ^C, so users may be able to obtain the behavior they want, without risking affecting the default behavior.

@rhatdan
Copy link
Member

rhatdan commented May 27, 2021

What happens when the --systemd flag is enabled, because you are using systemd within the container? We envisioned --systemd=always as mainly a debugging tool.

@ssbarnea
Copy link
Collaborator Author

Is not so much about what am I using and more about what others are using podman with. I maintain ansible molecule testing framework and I cannot prevent people from starting containers with systemd or not. The default is not, but a significant number do try to use system as they want to test deployment of various services.

IMHO, I am yet to see the first user that starts a container in console interactive mode but he does not want to be able to use Ctrl-C to stop it after. What is the purpose of starting a console app the you cannot stop? I think that exposing the tricks needed for stopping such runs could help improve overall user experience.

If you want I can survey few others about expectations and tell the to comment as I do not want to impose my view of what the cli should do or not. After digging these days I am sure I will not forget about the ^P^Q trick any time soon.

@rhatdan
Copy link
Member

rhatdan commented May 27, 2021

There are lots of tools that ignore ^c, so this is not that unusual.

@rhatdan
Copy link
Member

rhatdan commented May 27, 2021

$ podman run --systemd=always alpine sleep 100
^C
$

So if I run an application that does not ignore ctrl^c. then it works. If I launch Bash, it the ^c is passed to processes within the shell. We don't kill the session.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

4 participants