From 346c80d714c3445fc977a1b72293eac49adf1f5f Mon Sep 17 00:00:00 2001 From: lfbzhm Date: Fri, 8 Nov 2024 01:43:24 +0000 Subject: [PATCH 1/2] libct: replace unix.Kill with os.Process.Signal Because we should switch to unix.PidFDSendSignal in new kernels, it has been supported in go runtime. We don't need to add fall back to unix.Kill code here. Signed-off-by: lifubang Signed-off-by: Kir Kolyshkin --- libcontainer/process_linux.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index 88861f0a94d..5ac574bdeff 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -116,11 +116,7 @@ func (p *containerProcess) startTime() (uint64, error) { } func (p *containerProcess) signal(sig os.Signal) error { - s, ok := sig.(unix.Signal) - if !ok { - return errors.New("os: unsupported signal type") - } - return unix.Kill(p.pid(), s) + return p.cmd.Process.Signal(sig) } func (p *containerProcess) externalDescriptors() []string { From 1afa1b8662349d4c1ec1f8159aa5f022596a651f Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 7 Mar 2025 13:10:54 -0800 Subject: [PATCH 2/2] signals: replace unix.Kill with process.Signal This way, given a recent Go and Linux version, pidfd_send_signal will be used under the hood. Keep unix.Signal and unix.SignalName for logging (it is way more readable than what os.Signal.String() provides). Signed-off-by: Kir Kolyshkin --- signals.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signals.go b/signals.go index a992dc4abeb..936d751f61f 100644 --- a/signals.go +++ b/signals.go @@ -114,7 +114,7 @@ func (h *signalHandler) forward(process *libcontainer.Process, tty *tty, detach default: 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 { + if err := process.Signal(s); err != nil { logrus.Error(err) } }