Skip to content

Commit f090433

Browse files
shs96ccopybara-github
authored andcommitted
Rollback #14510 because it causes remote test execution to fail
When the parent process is run as a different user to the test itself (as can happen in some remote build environments, such as buildbarn) using `kill -0 $PPID` fails, causing the test to be prematurely killed. This PR rolls back the (nicer, cleaner, not always working) fix and replaces it with the (less nice, less clean, more often working) check that was there before. Tested with a local build against buildbarn. Closes #17147. PiperOrigin-RevId: 500691976 Change-Id: Ife55db5c1ed88d40ba502257ce9b679b04eeb179
1 parent afa2500 commit f090433

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tools/test/test-setup.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,18 @@ fi
331331
childPid=$!
332332

333333
# Cleanup helper
334-
# Assume that we don't have drastically reduced abilities to communicate signals
335-
# to our parent process. kill()ability means existence.
336-
( while kill -0 $PPID &> /dev/null; do # magic 0 sigspec tests deliverability only
334+
# It would be nice to use `kill -0 $PPID` here, but when whatever called this
335+
# is running as a different user (as happens in remote execution) that will
336+
# return an error, causing us to prematurely reap a running test.
337+
( if ! (ps -p $$ &> /dev/null || [ "`pgrep -a -g $$ 2> /dev/null`" != "" ] ); then
338+
# `ps` is known to be unrunnable in the darwin sandbox-exec environment due
339+
# to being a set-uid root program. pgrep exists in most environments, but not
340+
# universally. In the event that we find ourselves running in an environment
341+
# where *neither* exists, we have no reliable way to check if our parent is
342+
# still alive - so simply disable this cleanup routine entirely.
343+
exit 0
344+
fi
345+
while ps -p $$ &> /dev/null || [ "`pgrep -a -g $$ 2> /dev/null`" != "" ]; do
337346
sleep 10
338347
done
339348
# Parent process not found - we've been abandoned! Clean up test processes.

0 commit comments

Comments
 (0)