Merge pull request #4532 from cpuguy83/forward_signal_not_found
Fix some signal forwarder issues
This commit is contained in:
commit
7ce23867e3
@ -23,6 +23,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -36,8 +37,16 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal {
|
||||
signal.Notify(sigc)
|
||||
go func() {
|
||||
for s := range sigc {
|
||||
if canIgnoreSignal(s) {
|
||||
logrus.Debugf("Ignoring signal %s", s)
|
||||
continue
|
||||
}
|
||||
logrus.Debug("forwarding signal ", s)
|
||||
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil {
|
||||
if errdefs.IsNotFound(err) {
|
||||
logrus.WithError(err).Debugf("Not forwarding signal %s", s)
|
||||
return
|
||||
}
|
||||
logrus.WithError(err).Errorf("forward signal %s", s)
|
||||
}
|
||||
}
|
||||
|
27
cmd/ctr/commands/signals_linux.go
Normal file
27
cmd/ctr/commands/signals_linux.go
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func canIgnoreSignal(s os.Signal) bool {
|
||||
return s == unix.SIGURG
|
||||
}
|
25
cmd/ctr/commands/signals_notlinux.go
Normal file
25
cmd/ctr/commands/signals_notlinux.go
Normal file
@ -0,0 +1,25 @@
|
||||
//+build !linux
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package commands
|
||||
|
||||
import "os"
|
||||
|
||||
func canIgnoreSignal(_ os.Signal) bool {
|
||||
return false
|
||||
}
|
Loading…
Reference in New Issue
Block a user