From a1af2710f6c7dc570a51bfb96180b5f6d95edd87 Mon Sep 17 00:00:00 2001 From: wangjun Date: Wed, 25 Jun 2025 04:15:15 +0000 Subject: [PATCH 1/3] functions: avoid using array indices to get value form string Busybox-bash does not support "[]", fix it by "cut" Signed-off-by: wangjun --- etc/rc.d/init.d/functions | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/init.d/functions b/etc/rc.d/init.d/functions index 0d973b3f..d123cf42 100644 --- a/etc/rc.d/init.d/functions +++ b/etc/rc.d/init.d/functions @@ -117,10 +117,7 @@ __kill_pids_term_kill_checkpids() { for pid in $pids ; do [ ! -e "/proc/$pid" ] && continue - read -r line < "/proc/$pid/stat" 2> /dev/null - - stat=($line) - stime=${stat[21]} + stime=$(cat /proc/$pid/stat 2> /dev/null | cut -d" " -f22) [ -n "$stime" ] && [ "$base_stime" -lt "$stime" ] && continue remaining="$remaining$pid " @@ -141,8 +138,7 @@ __kill_pids_term_kill() { # We can't initialize stat & base_stime on the same line where 'local' # keyword is, otherwise the sourcing of this file will fail for ksh... - stat=($(< /proc/self/stat)) - base_stime=${stat[21]} + base_stime=$(cat /proc/$$/stat | cut -d" " -f22) if [ "$1" = "-d" ]; then delay=$2 From 5e65647255ad81880eaf22f3caab9011fe81e718 Mon Sep 17 00:00:00 2001 From: AlfredWJ <112916980+AlfredWJ@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:30:22 +0800 Subject: [PATCH 2/3] Update etc/rc.d/init.d/functions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- etc/rc.d/init.d/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/init.d/functions b/etc/rc.d/init.d/functions index d123cf42..6b09e8db 100644 --- a/etc/rc.d/init.d/functions +++ b/etc/rc.d/init.d/functions @@ -117,7 +117,7 @@ __kill_pids_term_kill_checkpids() { for pid in $pids ; do [ ! -e "/proc/$pid" ] && continue - stime=$(cat /proc/$pid/stat 2> /dev/null | cut -d" " -f22) + stime=$(cut -d" " -f22 /proc/$pid/stat 2> /dev/null) [ -n "$stime" ] && [ "$base_stime" -lt "$stime" ] && continue remaining="$remaining$pid " From 8ca0939eefdc7ebc2860ee421f4fe62fb974d50b Mon Sep 17 00:00:00 2001 From: AlfredWJ <112916980+AlfredWJ@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:30:37 +0800 Subject: [PATCH 3/3] Update etc/rc.d/init.d/functions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- etc/rc.d/init.d/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/init.d/functions b/etc/rc.d/init.d/functions index 6b09e8db..37d5dfcc 100644 --- a/etc/rc.d/init.d/functions +++ b/etc/rc.d/init.d/functions @@ -138,7 +138,7 @@ __kill_pids_term_kill() { # We can't initialize stat & base_stime on the same line where 'local' # keyword is, otherwise the sourcing of this file will fail for ksh... - base_stime=$(cat /proc/$$/stat | cut -d" " -f22) + base_stime=$(cut -d" " -f22 /proc/$$/stat) if [ "$1" = "-d" ]; then delay=$2