Skip to content

Commit

Permalink
Handle SIGWINCH under bazel run //some:test (i.e. test rules) cor…
Browse files Browse the repository at this point in the history
…rectly. (#17760)

Previously, after two window resize events we would stop waiting for the child process.

`wait` is interrupted by any trapped signal (and we trap all signals), so we need to call it in a loop until the child really exited.

Fixes #17215

Closes #17301.

PiperOrigin-RevId: 514395755
Change-Id: Ifb763a55d53f230cde8b1ca77761d94ea6e43e1f

Co-authored-by: Tobias Werth <twerth@google.com>
  • Loading branch information
ShreeM01 and meisterT authored Mar 15, 2023
1 parent 6fc9bed commit 055164c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,15 @@ cleanupPid=$!

set +m

# Wait until $childPid fully exits.
# We need to wait in a loop because wait is interrupted by any incoming trapped
# signal (https://www.gnu.org/software/bash/manual/bash.html#Signals).
while kill -0 $childPid 2>/dev/null; do
wait $childPid
done
# Wait one more time to retrieve the exit code.
wait $childPid
# If interrupted by a signal, use the signal as the exit code. But allow
# the child to actually finish from the signal we sent _it_ via signal_child.
# (Waiting on a stopped process is a no-op).
# Only once - if we receive multiple signals (of any sort), give up.
exitCode=$?
wait $childPid

# By this point, we have everything we're willing to wait for. Tidy up our own
# processes and move on.
Expand Down

0 comments on commit 055164c

Please sign in to comment.