-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Gradle does not propagate SIGINT to the docker run started by an exec task #8025
Comments
I've done some further investigation and even though imo it's unexpected, this is what Docker is doing: If you attach a pseudo-TTY ( If you also open The problem is, that when running from a Gradle task, Gradle does not allocate a pseudo-TTY for the spawned processes (and it's not a problem per se), so Docker gives you
All in all this is entirely Docker specific behavior, that's why it did not repro with any other program handling signals. Closing this, I'll try to comment providing a work around if I come up with something semi-decent. Background: moby/moby#2838 |
I've spent a bit more time with this problem and actually there seems to be some issue with signal propagation when Gradle daemon is involved, consider this minimal repro:
The task starts a sub-shell and defines a trap for |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request. |
Have same problem that Gradle isn't propagating SIGINT to sub-process: Shutdownhook isn't being triggered because of this. |
A simple and crappy work around is that I still used |
SIGINT
normally triggered byCtrl+C
stops the Gradle task execution but anydocker run
started by the task are left dangling and have to be cleaned up manually.Expected Behavior
The signal is propagated to all child processes.
Current Behavior
The signal is not propagated to
docker run
causing the processes to dangle unintentionally.Context
For my use case, I define a Gradle task which starts a Dockerized proxy server for local development. It is expected that the users run this task manually, as part of the local dev flow. The users should be able to see the proxy stdout and once they're done with it, stop it. The users commonly stop foreground processes by sending a
SIGINT
viaCtrl-C
in the terminal emulator of their choice.So it goes like this:
...
Ctrl-C
in the terminal emulator. This does not stop the proxy but only the Gradle execution.Steps to Reproduce (for bugs)
Define an exec task to spawn a long-running process
./gradlew runContainer
Ctrl+C
docker container list
./gradlew runContainer --no-daemon
(same as the above)
Your Environment
Additional context
I've tried to repro this with a simple program like
sleep
But it won't repro. Right now I can only repro this with
docker run -t
.The text was updated successfully, but these errors were encountered: