Skip to content

Commit

Permalink
signals: fix signal name debug print
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kolyshkin committed Feb 1, 2022
1 parent e9190d3 commit 58c1ff3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 58c1ff3

Please sign in to comment.