[packages/psmisc] - rel 2; fallback to kill() if pidfd_send_signal is not available - fixes working on older kernels l

arekm arekm at pld-linux.org
Tue Feb 7 11:39:15 CET 2023


commit b9412f717e26d5b78632ac63b3a9d71aefa1a404
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Feb 7 11:38:52 2023 +0100

    - rel 2; fallback to kill() if pidfd_send_signal is not available - fixes working on older kernels like 4.9

 kill.patch  | 41 +++++++++++++++++++++++++++++++++++++++++
 psmisc.spec |  4 +++-
 2 files changed, 44 insertions(+), 1 deletion(-)
---
diff --git a/psmisc.spec b/psmisc.spec
index f71d4e4..af777f4 100644
--- a/psmisc.spec
+++ b/psmisc.spec
@@ -14,13 +14,14 @@ Summary(tr.UTF-8):	/proc dosya sistemi için ps tipi araçlar
 Summary(uk.UTF-8):	Утиліти роботи з процесами
 Name:		psmisc
 Version:	23.5
-Release:	1
+Release:	2
 License:	GPL v2+
 Group:		Applications/System
 Source0:	https://downloads.sourceforge.net/psmisc/%{name}-%{version}.tar.xz
 # Source0-md5:	014f0b5d5ab32478a2c57812ad01e1fb
 Source1:	http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2
 # Source1-md5:	9add7665e440bbd6b0b4f9293ba8b86d
+Patch0:         kill.patch
 URL:		http://psmisc.sourceforge.net/
 BuildRequires:	autoconf >= 2.71
 BuildRequires:	automake >= 1:1.11
@@ -89,6 +90,7 @@ göndermek için gerekli programları içerir.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 install -d misc; echo -n '#!/bin/sh\necho -n %{version}' > misc/git-version-gen; chmod +x misc/git-version-gen
diff --git a/kill.patch b/kill.patch
new file mode 100644
index 0000000..f9232ec
--- /dev/null
+++ b/kill.patch
@@ -0,0 +1,41 @@
+commit 6892e321e7042e3df60a5501a1c59d076e8a856f
+Author: Craig Small <csmall at dropbear.xyz>
+Date:   Mon Jul 18 20:16:42 2022 +1000
+
+    killall: use kill if pidfd_send_signal() fails
+    
+    The pidfd_send_signal() system call appeared in Linux 5.1
+    If psmisc is build on a system before then, or a non-Linux
+    system, then kill() is used instead. However if psmisc is
+    built on a Linux >= 5.1 system but run on a < 5.1 Linux
+    system the system call fails and killall doesn't work.
+    
+    The fix, as proposed by Peter T. Breuer, is to try
+    pidfd_send_signal() and if the return value is < 0 and
+    errno is ENOSYS then we know at runtime the system call
+    failed and we fall through to trusty old kill().
+    
+    Note, this means that killall on systems below 5.1 still
+    have the race PID condition that the pidfd calls fix.
+    
+    References:
+     https://bugs.debian.org/1015228
+
+diff --git a/src/killall.c b/src/killall.c
+index 78930c8..f573cfe 100644
+--- a/src/killall.c
++++ b/src/killall.c
+@@ -326,7 +326,12 @@ my_send_signal(
+ {
+ #ifdef __NR_pidfd_send_signal
+     if (pid > 0) /* Not PGID */
+-        return syscall(__NR_pidfd_send_signal, pidfd, sig, NULL, 0);
++    {
++	int ret = syscall(__NR_pidfd_send_signal, pidfd, sig, NULL, 0);
++	if (ret >= 0 || errno != ENOSYS)
++	    return ret;
++	// fall through if no such syscall
++    }
+ #endif
+     return kill(pid, sig);
+ }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/psmisc.git/commitdiff/b9412f717e26d5b78632ac63b3a9d71aefa1a404



More information about the pld-cvs-commit mailing list