-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Interrupt signal is not proxied and "docker run" terminates #3801
Comments
I was confused for a bit, because I recalled we made a change in 20.10 to fix this (#1841), but I see this is specifically about Let me ask around if there's possibly a reason for excluding this specifically 🤔 |
Sure, thanks! In case you missed, moby/term#31 has some more information. |
Seems like signal handlers for INT on docker/cli and moby/term are also racing. Adding a sleep before exiting changes the behaviour as INT signal is then proxied correctly: @@ -10,6 +11,7 @@ import (
"io"
"os"
"os/signal"
+ "time"
"golang.org/x/sys/unix"
)
@@ -112,6 +114,7 @@ func handleInterrupt(fd uintptr, state *State) {
// quit cleanly and the new terminal item is on a new line
fmt.Println()
signal.Stop(sigchan)
+ time.Sleep(time.Second * 3)
close(sigchan)
RestoreTerminal(fd, state)
os.Exit(1)` |
Here is some ramble on why I think it would make sense to fix this:
I've got a vague feeling I forgot to mention something 🤷. Well, it would be kewl to have this. |
Sorry for not getting back to you. I did ask around if people knew if there was some reason they could come up with why the In those discussions, I suggested to at least try a "test" PR to see if everything works as intended; I just opened #3849, which uses the version of github.com/moby/term from your PR (moby/term#31) |
No worries! Happy to hear back from you. Thanks again for getting this forward. |
Description
Interrupt signal (SIGINT) is not proxied to the container when issued with
kill() to "docker run". Run command is terminated by the signal and container
is left running in the background.
This issue is seen on Linux when running a container attached with --tty (-t)
option and INT signal is sent from an external process with kill(). It's not
about CTRL+c INT that does indeed work as expected.
Embedding "docker run" in to software like editors is a bit tricky because of
this. For example, emacs compilation uses a tty by default, and it also
sends INT kill() instead of CTRL+c to the process group on "kill-compilation".
Pull request for moby/term: moby/term#31
Reproduce
docker run -it --rm --sig-proxy --init alpine sleep 3600
pkill --signal INT -f docker.*run.*sleep
Docker run dies and container is left behind
Expected behavior
Signal is proxied from docker run and container dies
docker version
docker info
Additional Info
No response
The text was updated successfully, but these errors were encountered: