From dd8ef8cc107a867d4b2a739913b399f6966b34ff Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 15:57:50 +0100 Subject: [PATCH 1/2] initscripts: Fix wrong variable check for $PIDFILE in getpids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getpids() checked whether it needed to pass a pid file to pidofproc, but the check was inverted. Signed-off-by: Daniel Weismüller --- src/initscripts/system/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 6f53a941b..e4cb30456 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -407,7 +407,7 @@ pidofproc() # This will ensure compatibility with previous LFS Bootscripts getpids() { - if [ -z "${PIDFILE}" ]; then + if [ -n "${PIDFILE}" ]; then pidofproc -s -p "${PIDFILE}" $@ else pidofproc -s $@ From c3019331df2bb393c96def62a56d33abdec72e8c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 11 Jan 2024 15:59:34 +0100 Subject: [PATCH 2/2] initscripts: Implement storing PIDs in loadproc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some programs do not write their own PID files any more, but since our initscripts heavily rely on those, this extension allows to store it easily. Signed-off-by: Daniel Weismüller --- src/initscripts/system/functions | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index e4cb30456..5a26aef45 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -446,6 +446,7 @@ loadproc() local pidfile="" local forcestart="" local nicelevel="" + local pid # This will ensure compatibility with previous LFS Bootscripts if [ -n "${PIDFILE}" ]; then @@ -521,12 +522,19 @@ loadproc() ( ${cmd} &>/dev/null ) & + pid="$!" evaluate_retval else ${cmd} + pid="$!" evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts fi + # Write the pidfile + if [ -n "${pid}" -a -n "${pidfile}" ]; then + echo "${pid}" > "${pidfile}" + fi + return 0 }