From 8d516cc28ee8b770e8f5d602eaeefc5840f39b9f Mon Sep 17 00:00:00 2001 From: m4air Date: Mon, 28 Sep 2026 07:37:06 -0700 Subject: [PATCH] test: avoid subprocesses when reading fixture process identities --- .../run-appimage-desktop-startup-case.sh | 9 ++++++--- config/scripts/appimage-startup-cleanup.test.mjs | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/docker/headless-serve-shutdown/run-appimage-desktop-startup-case.sh b/config/docker/headless-serve-shutdown/run-appimage-desktop-startup-case.sh index 291b60653fd..4cd873faa02 100755 --- a/config/docker/headless-serve-shutdown/run-appimage-desktop-startup-case.sh +++ b/config/docker/headless-serve-shutdown/run-appimage-desktop-startup-case.sh @@ -48,9 +48,12 @@ read_start_ticks() { local pid=$1 [[ -r "/proc/$pid/stat" ]] || return 1 local stat - stat=$(cat "/proc/$pid/stat") || return 1 + local -a fields + stat=$(<"/proc/$pid/stat") || return 1 # comm is parenthesized and may contain spaces or parentheses. - awk '{print $20}' <<< "${stat##*) }" + read -r -a fields <<< "${stat##*) }" + ((${#fields[@]} >= 20)) || return 1 + printf '%s\n' "${fields[19]}" } identity_alive() { @@ -208,8 +211,8 @@ report_launcher_exit() { cleanup() { local status=$? trap - EXIT - collect_state_processes TERM signal_process_group TERM || true + collect_state_processes TERM signal_owned_processes TERM || true if ! wait_for_owned_exit 10 TERM; then signal_process_group KILL || true diff --git a/config/scripts/appimage-startup-cleanup.test.mjs b/config/scripts/appimage-startup-cleanup.test.mjs index fc709686714..22f0325ddd9 100644 --- a/config/scripts/appimage-startup-cleanup.test.mjs +++ b/config/scripts/appimage-startup-cleanup.test.mjs @@ -12,7 +12,8 @@ const functions = oracle.slice(oracle.indexOf('read_start_ticks()'), oracle.inde function isRunning(pid) { try { - return readFileSync(`/proc/${pid}/stat`, 'utf8').split(') ')[1][0] !== 'Z' + const stat = readFileSync(`/proc/${pid}/stat`, 'utf8') + return stat.slice(stat.lastIndexOf(') ') + 2)[0] !== 'Z' } catch { return false }