Skip to content

Commit d118c90

Browse files
cpuguy83thaJeztah
authored andcommitted
Ignore SIGURG signals in signal forwarder
Starting with go1.14, the go runtime hijacks SIGURG but with no way to not send to other signal handlers. In practice, we get this signal frequently. I found this while testing out go1.15 with ctr and multiple execs with only `echo hello`. When the process exits quickly, if the previous commit is not applied, you end up with an error message that it couldn't forward SIGURG to the container (due to the process being gone). Signed-off-by: Brian Goff <[email protected]> (cherry picked from commit 899b4e3) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3ee6189 commit d118c90

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

cmd/ctr/commands/signals.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal {
3737
signal.Notify(sigc)
3838
go func() {
3939
for s := range sigc {
40+
if canIgnoreSignal(s) {
41+
logrus.Debugf("Ignoring signal %s", s)
42+
continue
43+
}
4044
logrus.Debug("forwarding signal ", s)
4145
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil {
4246
if errdefs.IsNotFound(err) {

cmd/ctr/commands/signals_linux.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package commands
18+
19+
import (
20+
"os"
21+
22+
"golang.org/x/sys/unix"
23+
)
24+
25+
func canIgnoreSignal(s os.Signal) bool {
26+
return s == unix.SIGURG
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//+build !linux
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package commands
20+
21+
import "os"
22+
23+
func canIgnoreSignal(_ os.Signal) bool {
24+
return false
25+
}

0 commit comments

Comments
 (0)