mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
test: avoid subprocesses when reading fixture process identities
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user