Skip to content

Commit 6b5fc7f

Browse files
authored
Merge pull request #4542 from thaJeztah/1.4_backport_forward_signal_not_found
[release/1.4 backport] Fix some signal forwarder issues
2 parents 1a36776 + d118c90 commit 6b5fc7f

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

cmd/ctr/commands/signals.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"syscall"
2424

2525
"github.com/containerd/containerd"
26+
"github.com/containerd/containerd/errdefs"
2627
"github.com/sirupsen/logrus"
2728
)
2829

@@ -36,8 +37,16 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal {
3637
signal.Notify(sigc)
3738
go func() {
3839
for s := range sigc {
40+
if canIgnoreSignal(s) {
41+
logrus.Debugf("Ignoring signal %s", s)
42+
continue
43+
}
3944
logrus.Debug("forwarding signal ", s)
4045
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil {
46+
if errdefs.IsNotFound(err) {
47+
logrus.WithError(err).Debugf("Not forwarding signal %s", s)
48+
return
49+
}
4150
logrus.WithError(err).Errorf("forward signal %s", s)
4251
}
4352
}

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)