Remove bash specific code
Use case pattern matching instead of multiline split, given there is only the well formatted PIDs to match on this should be safe. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
58ed8a7594
commit
e05e126933
1 changed files with 10 additions and 14 deletions
|
@ -626,6 +626,8 @@ has_mem_err() {
|
||||||
# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
|
# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
|
||||||
if type lsof >/dev/null 2>/dev/null; then
|
if type lsof >/dev/null 2>/dev/null; then
|
||||||
wait_app_start() {
|
wait_app_start() {
|
||||||
|
newline='
|
||||||
|
'
|
||||||
START_TIME=$(date +%s)
|
START_TIME=$(date +%s)
|
||||||
if [ "$DTLS" -eq 1 ]; then
|
if [ "$DTLS" -eq 1 ]; then
|
||||||
proto=UDP
|
proto=UDP
|
||||||
|
@ -634,20 +636,14 @@ if type lsof >/dev/null 2>/dev/null; then
|
||||||
fi
|
fi
|
||||||
# Make a tight loop, server normally takes less than 1s to start.
|
# Make a tight loop, server normally takes less than 1s to start.
|
||||||
while true; do
|
while true; do
|
||||||
SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p | cut -c2-)
|
SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p)
|
||||||
SERVER_FOUND=false
|
# When we use a proxy, it will be listening on the same port we
|
||||||
# When proxies are used, more than one PID can be listening on
|
# are checking for as well as the server and lsof will list both.
|
||||||
# the same port. Each PID will be on its own line.
|
# If multiple PIDs are returned, each one will be on a separate
|
||||||
while read -r PID; do
|
# line, each prepended with 'p'.
|
||||||
if [[ $PID == $2 ]]; then
|
case ${newline}${SERVER_PIDS}${newline} in
|
||||||
SERVER_FOUND=true
|
*${newline}p${2}${newline}*) break;;
|
||||||
break
|
esac
|
||||||
fi
|
|
||||||
done <<< "$SERVER_PIDS"
|
|
||||||
|
|
||||||
if ($SERVER_FOUND == true); then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
|
if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
|
||||||
echo "$3 START TIMEOUT"
|
echo "$3 START TIMEOUT"
|
||||||
echo "$3 START TIMEOUT" >> $4
|
echo "$3 START TIMEOUT" >> $4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue