-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[20.10 backport] Ignore SIGURG on Unix (including Darwin) #3107
Merged
silvin-lubecki
merged 4 commits into
docker:20.10
from
thaJeztah:20.10_backport_sigurg_handling
May 31, 2021
Merged
[20.10 backport] Ignore SIGURG on Unix (including Darwin) #3107
silvin-lubecki
merged 4 commits into
docker:20.10
from
thaJeztah:20.10_backport_sigurg_handling
May 31, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit f33a69f. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
We refactorted `ForwardAllSignals` so it blocks but did not update the call in `start` to call it in a goroutine. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit e1a7517) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Commit fff164c modified ForwardAllSignals to take `SIGURG` signals into account, which can be generated by the Go runtime on Go 1.14 and up as an interrupt to support pre-emptable system calls on Linux. With the updated code, the signal (`s`) would sometimes be `nil`, causing spurious (but otherwise harmless) warnings to be printed; Unsupported signal: <nil>. Discarding. To debug this issue, I patched v20.10.4 to handle `nil`, and added a debug line to print the signal in all cases; ```patch diff --git a/cli/command/container/signals.go b/cli/command/container/signals.go index 06e4d9eb6..0cb53ef06 100644 --- a/cli/command/container/signals.go +++ b/cli/command/container/signals.go @@ -22,8 +22,9 @@ func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string, sigc <- case <-ctx.Done(): return } + fmt.Fprintf(cli.Err(), "Signal: %v\n", s) if s == signal.SIGCHLD || s == signal.SIGPIPE { ``` When running a cross-compiled macOS binary with Go 1.13 (`make -f docker.Makefile binary-osx`): # regular "docker run" (note that the `<nil>` signal only happens "sometimes"): ./build/docker run --rm alpine/git clone https://github.com/docker/getting-started.git Cloning into 'getting-started'... Signal: <nil> # when cancelling with CTRL-C: ./build/docker run --rm alpine/git clone https://github.com/docker/getting-started.git ^CSignal: interrupt Cloning into 'getting-started'... error: could not lock config file /git/getting-started/.git/config: No such file or directory fatal: could not set 'core.repositoryformatversion' to '0' Signal: <nil> Signal: <nil> When running a macOS binary built with Go 1.15 (`DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary`): # regular "docker run" (note that the `<nil>` signal only happens "sometimes"): # this is the same as on Go 1.13 ./build/docker run --rm alpine/git clone https://github.com/docker/getting-started.git Cloning into 'getting-started'... Signal: <nil> # when cancelling with CTRL-C: ./build/docker run --rm alpine/git clone https://github.com/docker/getting-started.git Cloning into 'getting-started'... ^CSignal: interrupt Signal: urgent I/O condition Signal: urgent I/O condition fatal: --stdin requires a git repository fatal: index-pack failed Signal: <nil> Signal: <nil> This patch checks if the channel is closed, and removes the warning (to prevent warnings if new signals are added that are not in our known list of signals) We should also consider updating `notfiyAllSignals()`, which currently forwards _all_ signals (`signal.Notify(sigc)` without passing a list of signals), and instead pass it "all signals _minus_ the signals we don't want forwarded": https://github.com/docker/cli/blob/35f023a7c22a51867fb099d29006ef27379bc7fe/cli/command/container/signals.go#L55 Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 9342ec6) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This extends docker#2929 to Darwin as well as Linux. Running the example in golang/go#37942 I see lots of: ``` dave@m1 sigurg % uname -ms Darwin arm64 dave@m1 sigurg % go run main.go received urgent I/O condition: 2021-05-21 16:03:03.482211 +0100 BST m=+0.014553751 received urgent I/O condition: 2021-05-21 16:03:03.507171 +0100 BST m=+0.039514459 ``` Signed-off-by: David Scott <dave@recoil.org> (cherry picked from commit cedaf44) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
cpuguy83
approved these changes
May 25, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@tonistiigi ptal 🤗 |
silvin-lubecki
approved these changes
May 31, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes moby/moby#41985
relates to / addresses docker/for-mac#5712 Shell exits before accepting command when using --init option
this un-reverts #2960 (reverted in #2987), thus re-applying #2929, and backports the follow-up pull requests that have fixes for the original change:
docker start
blocking on signal handling #2990 Fix docker start blocking on signal handling- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)