Skip to content

Commit

Permalink
[20.10] Revert "Ignore SIGURG on Linux."
Browse files Browse the repository at this point in the history
This reverts commit 3c87f01.

This commit introduced two regressions;

- spurious "Unsupported signal: <nil>. Discarding."
- docker start --attach hanging if the container does not
  have a TTY attached

Reverting for now, while we dug deeper into what's causing
the regression.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Mar 1, 2021
1 parent d3cb89e commit f33a69f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 196 deletions.
3 changes: 1 addition & 2 deletions cli/command/container/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ func runAttach(dockerCli command.Cli, opts *attachOptions) error {
}

if opts.proxy && !c.Config.Tty {
sigc := notfiyAllSignals()
go ForwardAllSignals(ctx, dockerCli, opts.container, sigc)
sigc := ForwardAllSignals(ctx, dockerCli, opts.container)
defer signal.StopCatch(sigc)
}

Expand Down
8 changes: 0 additions & 8 deletions cli/command/container/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type fakeClient struct {
containerExportFunc func(string) (io.ReadCloser, error)
containerExecResizeFunc func(id string, options types.ResizeOptions) error
containerRemoveFunc func(ctx context.Context, container string, options types.ContainerRemoveOptions) error
containerKillFunc func(ctx context.Context, container, signal string) error
Version string
}

Expand Down Expand Up @@ -155,10 +154,3 @@ func (f *fakeClient) ContainerExecResize(_ context.Context, id string, options t
}
return nil
}

func (f *fakeClient) ContainerKill(ctx context.Context, container, signal string) error {
if f.containerKillFunc != nil {
return f.containerKillFunc(ctx, container, signal)
}
return nil
}
3 changes: 1 addition & 2 deletions cli/command/container/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptio
return runStartContainerErr(err)
}
if opts.sigProxy {
sigc := notfiyAllSignals()
go ForwardAllSignals(ctx, dockerCli, createResponse.ID, sigc)
sigc := ForwardAllSignals(ctx, dockerCli, createResponse.ID)
defer signal.StopCatch(sigc)
}

Expand Down
57 changes: 0 additions & 57 deletions cli/command/container/signals.go

This file was deleted.

11 changes: 0 additions & 11 deletions cli/command/container/signals_linux.go

This file was deleted.

57 changes: 0 additions & 57 deletions cli/command/container/signals_linux_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions cli/command/container/signals_notlinux.go

This file was deleted.

48 changes: 0 additions & 48 deletions cli/command/container/signals_test.go

This file was deleted.

3 changes: 1 addition & 2 deletions cli/command/container/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ func runStart(dockerCli command.Cli, opts *startOptions) error {

// We always use c.ID instead of container to maintain consistency during `docker start`
if !c.Config.Tty {
sigc := notfiyAllSignals()
ForwardAllSignals(ctx, dockerCli, c.ID, sigc)
sigc := ForwardAllSignals(ctx, dockerCli, c.ID)
defer signal.StopCatch(sigc)
}

Expand Down
29 changes: 29 additions & 0 deletions cli/command/container/tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,32 @@ func MonitorTtySize(ctx context.Context, cli command.Cli, id string, isExec bool
}
return nil
}

// ForwardAllSignals forwards signals to the container
func ForwardAllSignals(ctx context.Context, cli command.Cli, cid string) chan os.Signal {
sigc := make(chan os.Signal, 128)
signal.CatchAll(sigc)
go func() {
for s := range sigc {
if s == signal.SIGCHLD || s == signal.SIGPIPE {
continue
}
var sig string
for sigStr, sigN := range signal.SignalMap {
if sigN == s {
sig = sigStr
break
}
}
if sig == "" {
fmt.Fprintf(cli.Err(), "Unsupported signal: %v. Discarding.\n", s)
continue
}

if err := cli.Client().ContainerKill(ctx, cid, sig); err != nil {
logrus.Debugf("Error sending signal: %s", err)
}
}
}()
return sigc
}

0 comments on commit f33a69f

Please sign in to comment.