From 58c1ff39a549636621de02ac32eb4a40d7665047 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 31 Jan 2022 11:44:48 -0800 Subject: [PATCH] signals: fix signal name debug print Here's how it looks now: $ runc --debug exec ctid sleep 1h ... DEBU[0000]signals.go:102 main.(*signalHandler).forward() sending signal to process urgent I/O condition DEBU[0000]signals.go:102 main.(*signalHandler).forward() sending signal to process urgent I/O condition DEBU[0022]signals.go:102 main.(*signalHandler).forward() sending signal to process terminated DEBU[0022]signals.go:102 main.(*signalHandler).forward() sending signal to process urgent I/O condition This is obviously not very readable. Use unix.SignalName, plus a numeric representation of the signal, since SignalName does not know all signals. Add PID while we're at it. With this commit: DEBU[0000]signals.go:103 main.(*signalHandler).forward() forwarding signal 23 (SIGURG) to 891345 DEBU[0020]signals.go:103 main.(*signalHandler).forward() forwarding signal 45 () to 891345 DEBU[0020]signals.go:103 main.(*signalHandler).forward() forwarding signal 23 (SIGURG) to 891345 DEBU[0020]signals.go:103 main.(*signalHandler).forward() forwarding signal 23 (SIGURG) to 891345 Signed-off-by: Kir Kolyshkin --- signals.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/signals.go b/signals.go index 2555b765b..473037607 100644 --- a/signals.go +++ b/signals.go @@ -99,8 +99,9 @@ func (h *signalHandler) forward(process *libcontainer.Process, tty *tty, detach } } default: - logrus.Debugf("sending signal to process %s", s) - if err := unix.Kill(pid1, s.(unix.Signal)); err != nil { + us := s.(unix.Signal) + logrus.Debugf("forwarding signal %d (%s) to %d", int(us), unix.SignalName(us), pid1) + if err := unix.Kill(pid1, us); err != nil { logrus.Error(err) } }