Skip to content

Commit a4d0067

Browse files
committed
pkg/signal: rework CatchAll() behavior
Instead of catching all signals and then ignoring them inside the loop again just don't register them in Notify() to begin with. Signed-off-by: Paul Holzinger <[email protected]>
1 parent 8de2e0e commit a4d0067

File tree

7 files changed

+13
-16
lines changed

7 files changed

+13
-16
lines changed

pkg/domain/infra/abi/terminal/sigproxy_commn.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ func ProxySignals(ctr *libpod.Container) {
2828
go func() {
2929
for s := range sigBuffer {
3030
syscallSignal := s.(syscall.Signal)
31-
if signal.IsSignalIgnoredBySigProxy(syscallSignal) {
32-
continue
33-
}
3431

3532
if err := ctr.Kill(uint(syscallSignal)); err != nil {
3633
// If the container is no longer running/removed do not log it as error.

pkg/domain/infra/tunnel/runtime.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ func remoteProxySignals(ctrID string, killFunc func(string) error) {
4646
go func() {
4747
for s := range sigBuffer {
4848
syscallSignal := s.(syscall.Signal)
49-
if signal.IsSignalIgnoredBySigProxy(syscallSignal) {
50-
continue
51-
}
5249
signalName, err := signal.ParseSysSignalToName(syscallSignal)
5350
if err != nil {
5451
logrus.Infof("Ceasing signal %v forwarding to container %s as it has stopped: %s", s, ctrID, err)

pkg/signal/signal_common.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ func ParseSignalNameOrNumber(rawSignal string) (syscall.Signal, error) {
4646
return -1, fmt.Errorf("invalid signal: %s", basename)
4747
}
4848

49-
// CatchAll catches all signals and relays them to the specified channel.
49+
// CatchAll catches all signals (except the ones that make no sense to handle/forward,
50+
// see isSignalIgnoredBySigProxy()) and relays them to the specified channel.
5051
func CatchAll(sigc chan os.Signal) {
5152
handledSigs := make([]os.Signal, 0, len(SignalMap))
5253
for _, s := range SignalMap {
53-
handledSigs = append(handledSigs, s)
54+
if !isSignalIgnoredBySigProxy(s) {
55+
handledSigs = append(handledSigs, s)
56+
}
5457
}
5558
signal.Notify(sigc, handledSigs...)
5659
}

pkg/signal/signal_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ var SignalMap = map[string]syscall.Signal{
8989
"RTMAX": sigrtmax,
9090
}
9191

92-
// IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
93-
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
92+
// isSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
93+
func isSignalIgnoredBySigProxy(s syscall.Signal) bool {
9494
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
9595
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
9696
// https://github.com/containers/podman/issues/5483

pkg/signal/signal_linux_mipsx.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ var SignalMap = map[string]syscall.Signal{
8989
"RTMAX": sigrtmax,
9090
}
9191

92-
// IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
93-
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
92+
// isSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
93+
func isSignalIgnoredBySigProxy(s syscall.Signal) bool {
9494
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
9595
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
9696
// https://github.com/containers/podman/issues/5483

pkg/signal/signal_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ var SignalMap = map[string]syscall.Signal{
8787
"RTMAX": sigrtmax,
8888
}
8989

90-
// IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
91-
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
90+
// isSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
91+
func isSignalIgnoredBySigProxy(s syscall.Signal) bool {
9292
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
9393
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
9494
// https://github.com/containers/podman/issues/5483

pkg/signal/signal_unsupported.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ var SignalMap = map[string]syscall.Signal{
8787
"RTMAX": sigrtmax,
8888
}
8989

90-
// IsSignalIgnoredBySigProxy determines whether to sig-proxy should ignore syscall signal
90+
// isSignalIgnoredBySigProxy determines whether to sig-proxy should ignore syscall signal
9191
// keep the container running or not. In unsupported OS this should not ignore any syscall signal.
92-
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
92+
func isSignalIgnoredBySigProxy(_ syscall.Signal) bool {
9393
return false
9494
}

0 commit comments

Comments
 (0)