initscripts: Fix process check for processes with PID file

Message ID 20250729143654.1331503-1-michael.tremer@ipfire.org
State New
Headers
Series initscripts: Fix process check for processes with PID file |

Commit Message

Michael Tremer 29 Jul 2025, 2:36 p.m. UTC
This check tests whether a process is still alive, but it fails for
those processes when we are using a PID file.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/system/functions | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions
index 85eb3e975..c4b7cb39e 100644
--- a/src/initscripts/system/functions
+++ b/src/initscripts/system/functions
@@ -620,7 +620,11 @@  killproc()
 	done
 
 	if [ -z "${killsig}" ];	then
-		pidofproc -s "${1}"
+		if [ -z "${pidfile}" ];	then
+			pidofproc -s "${1}"
+		else
+			pidofproc -s -p "${pidfile}" "${1}"
+		fi
 
 		# Program was terminated
 		if [ "$?" != "0" ]; then