|
- # Copyright (c) 2022 Jan Lehnardt <jan@apache.org>, MIT licensed
-
- . ./lib.sh
-
- wait_for_pid_exit () {
- assert_arg "$1" && pid="$1" || error_and_exit "pid not provided, exiting"
- assert_arg "$2" && iterations="$2" || iterations=3
- assert_arg "$3" && duration="$3" || duration=1
-
- debug "called wait_for_url(pid=pid, duration=$duration, iterations=$iterations)"
-
- waiting=0
-
- debug_inline "waiting for $pid to exit "
- until ( ! ps ax | grep $pid | grep -v grep > /dev/null); do
- if [ $waiting -eq $iterations ]; then
- let after=$duration*iterations
- debug_inline "failed, $pid still running after $after seconds\n"
- return 1
- fi
- debug_inline .
- let waiting=waiting+1
- sleep $duration
- done
- debug_inline " succeeded\n"
- }
|