mirror of
https://github.com/containers/podman.git
synced 2025-07-04 01:48:28 +08:00
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 <pholzing@redhat.com>
This commit is contained in:
@ -28,9 +28,6 @@ func ProxySignals(ctr *libpod.Container) {
|
|||||||
go func() {
|
go func() {
|
||||||
for s := range sigBuffer {
|
for s := range sigBuffer {
|
||||||
syscallSignal := s.(syscall.Signal)
|
syscallSignal := s.(syscall.Signal)
|
||||||
if signal.IsSignalIgnoredBySigProxy(syscallSignal) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ctr.Kill(uint(syscallSignal)); err != nil {
|
if err := ctr.Kill(uint(syscallSignal)); err != nil {
|
||||||
// If the container is no longer running/removed do not log it as error.
|
// If the container is no longer running/removed do not log it as error.
|
||||||
|
@ -46,9 +46,6 @@ func remoteProxySignals(ctrID string, killFunc func(string) error) {
|
|||||||
go func() {
|
go func() {
|
||||||
for s := range sigBuffer {
|
for s := range sigBuffer {
|
||||||
syscallSignal := s.(syscall.Signal)
|
syscallSignal := s.(syscall.Signal)
|
||||||
if signal.IsSignalIgnoredBySigProxy(syscallSignal) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
signalName, err := signal.ParseSysSignalToName(syscallSignal)
|
signalName, err := signal.ParseSysSignalToName(syscallSignal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Infof("Ceasing signal %v forwarding to container %s as it has stopped: %s", s, ctrID, err)
|
logrus.Infof("Ceasing signal %v forwarding to container %s as it has stopped: %s", s, ctrID, err)
|
||||||
|
@ -46,12 +46,15 @@ func ParseSignalNameOrNumber(rawSignal string) (syscall.Signal, error) {
|
|||||||
return -1, fmt.Errorf("invalid signal: %s", basename)
|
return -1, fmt.Errorf("invalid signal: %s", basename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CatchAll catches all signals and relays them to the specified channel.
|
// CatchAll catches all signals (except the ones that make no sense to handle/forward,
|
||||||
|
// see isSignalIgnoredBySigProxy()) and relays them to the specified channel.
|
||||||
func CatchAll(sigc chan os.Signal) {
|
func CatchAll(sigc chan os.Signal) {
|
||||||
handledSigs := make([]os.Signal, 0, len(SignalMap))
|
handledSigs := make([]os.Signal, 0, len(SignalMap))
|
||||||
for _, s := range SignalMap {
|
for _, s := range SignalMap {
|
||||||
|
if !isSignalIgnoredBySigProxy(s) {
|
||||||
handledSigs = append(handledSigs, s)
|
handledSigs = append(handledSigs, s)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
signal.Notify(sigc, handledSigs...)
|
signal.Notify(sigc, handledSigs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ var SignalMap = map[string]syscall.Signal{
|
|||||||
"RTMAX": sigrtmax,
|
"RTMAX": sigrtmax,
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
|
// isSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
|
||||||
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
func isSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
||||||
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
|
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
|
||||||
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
|
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
|
||||||
// https://github.com/containers/podman/issues/5483
|
// https://github.com/containers/podman/issues/5483
|
||||||
|
@ -89,8 +89,8 @@ var SignalMap = map[string]syscall.Signal{
|
|||||||
"RTMAX": sigrtmax,
|
"RTMAX": sigrtmax,
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
|
// isSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
|
||||||
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
func isSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
||||||
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
|
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
|
||||||
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
|
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
|
||||||
// https://github.com/containers/podman/issues/5483
|
// https://github.com/containers/podman/issues/5483
|
||||||
|
@ -87,8 +87,8 @@ var SignalMap = map[string]syscall.Signal{
|
|||||||
"RTMAX": sigrtmax,
|
"RTMAX": sigrtmax,
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
|
// isSignalIgnoredBySigProxy determines whether sig-proxy should ignore syscall signal
|
||||||
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
func isSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
||||||
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
|
// Ignore SIGCHLD and SIGPIPE - these are most likely intended for the podman command itself.
|
||||||
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
|
// SIGURG was added because of golang 1.14 and its preemptive changes causing more signals to "show up".
|
||||||
// https://github.com/containers/podman/issues/5483
|
// https://github.com/containers/podman/issues/5483
|
||||||
|
@ -87,8 +87,8 @@ var SignalMap = map[string]syscall.Signal{
|
|||||||
"RTMAX": sigrtmax,
|
"RTMAX": sigrtmax,
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsSignalIgnoredBySigProxy determines whether to sig-proxy should ignore syscall signal
|
// isSignalIgnoredBySigProxy determines whether to sig-proxy should ignore syscall signal
|
||||||
// keep the container running or not. In unsupported OS this should not ignore any syscall signal.
|
// keep the container running or not. In unsupported OS this should not ignore any syscall signal.
|
||||||
func IsSignalIgnoredBySigProxy(s syscall.Signal) bool {
|
func isSignalIgnoredBySigProxy(_ syscall.Signal) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user