Merge pull request #6917 from yanrayw/6658-not-print-Terminated-ubuntu-22.04

Fix the problem of printing "Terminated" in compat.sh under Ubuntu-22.04
This commit is contained in:
Gilles Peskine 2023-01-26 21:53:33 +01:00 committed by GitHub
commit 81505e4a16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -753,15 +753,17 @@ start_server() {
echo "$SERVER_CMD" > $SRV_OUT
# for servers without -www or equivalent
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
stop_server() {
kill $PROCESS_ID 2>/dev/null
wait $PROCESS_ID 2>/dev/null
# For Ubuntu 22.04, `Terminated` message is outputed by wait command.
# 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 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)
cleanup() {
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
exit 1
}
@ -790,11 +792,13 @@ wait_client_done() {
( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
WATCHDOG_PID=$!
wait $CLI_PID
# For Ubuntu 22.04, `Terminated` message is outputed by wait command.
# To remove it from stdout, redirect stdout/stderr to CLI_OUT
wait $CLI_PID >> $CLI_OUT 2>&1
EXIT=$?
kill $WATCHDOG_PID
wait $WATCHDOG_PID
kill $WATCHDOG_PID >/dev/null 2>&1
wait $WATCHDOG_PID >> $CLI_OUT 2>&1
echo "EXIT: $EXIT" >> $CLI_OUT
}