diff --git a/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh b/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh index ac0f4d27a5..6ceecb99d4 100755 --- a/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh +++ b/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh @@ -12,8 +12,20 @@ sync_in() { } wait_for_signal() { + local notify="${1:?}" + local p + sleep infinity & - wait "$!" || : + p=$! + + # Notify readiness after 'sleep' is running to avoid race + # condition where the SIGHUP is sent before 'sleep' is ready to + # receive it and we get stuck + if [ "$notify" -eq 1 ]; then + systemd-notify --ready + fi + + wait "$p" || : } sighup_handler() { @@ -24,17 +36,14 @@ trap sighup_handler SIGHUP export SYSTEMD_LOG_LEVEL=debug -systemd-notify --ready - -wait_for_signal +wait_for_signal 1 systemd-notify --reloading -wait_for_signal +wait_for_signal 0 systemd-notify --reloading sync_in ready -systemd-notify --ready -wait_for_signal +wait_for_signal 1 systemd-notify --reloading --ready exec sleep infinity