Redirect stdout/stderr to SRV_OUT

Under Ubuntu-22.04, wait command prints out Terminated message.
Therefore server process is handled with identical ways like other
processes in compat.sh. In addition, PROCESS_ID is renamed as
SRV_PID to improve code readability.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2023-01-13 11:42:11 +08:00
parent 05f940b255
commit 128859725a

View file

@ -753,15 +753,17 @@ start_server() {
echo "$SERVER_CMD" > $SRV_OUT echo "$SERVER_CMD" > $SRV_OUT
# for servers without -www or equivalent # for servers without -www or equivalent
while :; do echo bla; sleep 1; done | $SERVER_CMD >> $SRV_OUT 2>&1 & while :; do echo bla; sleep 1; done | $SERVER_CMD >> $SRV_OUT 2>&1 &
PROCESS_ID=$! SRV_PID=$!
wait_server_start "$PORT" "$PROCESS_ID" wait_server_start "$PORT" "$SRV_PID"
} }
# terminate the running server # terminate the running server
stop_server() { stop_server() {
kill $PROCESS_ID 2>/dev/null # For Ubuntu 22.04, `Terminated` message is outputed by wait command.
wait $PROCESS_ID 2>/dev/null # To remove it from stdout, redirect stdout/stderr to SRV_OUT
kill $SRV_PID >/dev/null 2>&1
wait $SRV_PID >> $SRV_OUT 2>&1
if [ "$MEMCHECK" -gt 0 ]; then if [ "$MEMCHECK" -gt 0 ]; then
if is_mbedtls "$SERVER_CMD" && has_mem_err $SRV_OUT; then if is_mbedtls "$SERVER_CMD" && has_mem_err $SRV_OUT; then
@ -777,7 +779,7 @@ stop_server() {
# kill the running server (used when killed by signal) # kill the running server (used when killed by signal)
cleanup() { cleanup() {
rm -f $SRV_OUT $CLI_OUT rm -f $SRV_OUT $CLI_OUT
kill $PROCESS_ID >/dev/null 2>&1 kill $SRV_PID >/dev/null 2>&1
kill $WATCHDOG_PID >/dev/null 2>&1 kill $WATCHDOG_PID >/dev/null 2>&1
exit 1 exit 1
} }