diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-08-24 17:21:26 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-08-24 17:22:54 -0400 |
commit | f009a6b0eceff84125a3e274dc2c6c2394ea7c0d (patch) | |
tree | 1f11f89edce7aa18f1bded3febfad6d9091a1b68 | |
parent | f2a1385c0e625494f5b4888954c8764850eba7b3 (diff) |
lib/supervisor: Exit when child exists
Previously, the supervisor would run until the timeout when the child
died (e.g. because of a build error). This adds a signal handler for
SIGCHLD to fix this silly bug.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | ci/_test-git-branch.sh | 2 | ||||
-rw-r--r-- | lib/supervisor.c | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/ci/_test-git-branch.sh b/ci/_test-git-branch.sh index 08ca5a5..a4ccd5a 100644 --- a/ci/_test-git-branch.sh +++ b/ci/_test-git-branch.sh @@ -82,7 +82,7 @@ while (( ${#SUBTESTS[@]} )); do $KTEST_DIR/lib/supervisor -T 1200 -f "$FULL_LOG" -S -F \ -b $TEST_NAME -o ktest-out/out \ - build-test-kernel run $TEST_PATH ${SUBTESTS[@]} & + -- build-test-kernel run $TEST_PATH ${SUBTESTS[@]} & wait SUBTESTS_REMAINING=() diff --git a/lib/supervisor.c b/lib/supervisor.c index ca472d1..f1d95cc 100644 --- a/lib/supervisor.c +++ b/lib/supervisor.c @@ -67,6 +67,12 @@ static void term_handler(int sig) exit(EXIT_FAILURE); } +static void child_handler(int sig) +{ + /* If the child exits early we treat it as a test failure: */ + exit(EXIT_FAILURE); +} + static void alarm_handler(int sig) { char *msg = mprintf("========= FAILED TIMEOUT %s in %lus\n", @@ -310,6 +316,10 @@ int main(int argc, char *argv[]) ssize_t len; char *line = NULL; + struct sigaction child_action = { .sa_handler = child_handler }; + if (sigaction(SIGCHLD, &child_action, NULL)) + die("sigaction error: %m"); + struct sigaction alarm_action = { .sa_handler = alarm_handler }; if (sigaction(SIGALRM, &alarm_action, NULL)) die("sigaction error: %m"); |