Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,10 @@ function func_exit_handler()

# get ps command result as list
local -a cmd_lst
# $$ as current script pid
# NOTICE: already test with $BASHPID:
# it can output the same result of $$
# but the result could not be stored in the array
readarray -t cmd_lst < <(pgrep -P $$ -a|grep -v "$SCRIPT_NAME")
# can't run pgrep in any subshell because the latter would pollute the list
if pgrep -P $$ -a > "$LOG_ROOT/children_left.txt"; then
readarray -t cmd_lst < "$LOG_ROOT/children_left.txt"
# now force kill target process which maybe block the script quit
if [ ${#cmd_lst[@]} -gt 0 ]; then
local line
dlogw "Process(es) started by $SCRIPT_NAME are still active, kill these process(es):"
for line in "${cmd_lst[@]}"
Expand All @@ -79,6 +76,8 @@ function func_exit_handler()
dlogw "Kill cmd:'${line#* }' by kill -9"
kill -9 "${line%% *}"
done
else
rm "$LOG_ROOT/children_left.txt"
fi

# check if function already defined.
Expand Down
2 changes: 1 addition & 1 deletion case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCRIPT_HOME="$(dirname "$0")"
# get test-case parent folder name
SCRIPT_HOME=$(cd "$SCRIPT_HOME/.." && pwd)
# shellcheck disable=SC2034 # external script can use it
SCRIPT_NAME="$0" # get test-case script load name
: "${SCRIPT_NAME:="$0"}" # get test-case script load name
# shellcheck disable=SC2034 # external script can use it
SCRIPT_PRAM="$*" # get test-case parameter

Expand Down
2 changes: 1 addition & 1 deletion case-lib/opt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func_opt_parse_option()

_func_case_dump_descption()
{
grep '^##' "$SCRIPT_NAME"|sed 's/^##//g'
grep '^##' "$0"|sed 's/^##//g'
}

# Asks getopt to validate command line input and generate $_op_temp_script
Expand Down
1 change: 1 addition & 0 deletions test-case/check-playback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

set -e

SCRIPT_NAME=BOGUS-check-playback
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh

Expand Down