tests: Improve fork/waitpid error handling

A couple of places in our test code aren't handling errors from fork()
or waitpid() properly. We don't expect to ever hit errors for these,
but sysbail() in this case, so they don't fail silently.

Change-Id: I1c548f93f4d4ac4344032d7847470b04319386f2
Reviewed-on: https://gerrit.openafs.org/14865
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2021-11-23 15:52:23 -06:00 committed by Benjamin Kaduk
parent a737126035
commit 7448cd159d
2 changed files with 5 additions and 2 deletions

View File

@ -441,7 +441,8 @@ int main(int argc, char **argv)
printf("Config directory is %s\n", dirname);
serverPid = fork();
if (serverPid == -1) {
/* Bang */
sysbail("fork");
} else if (serverPid == 0) {
execl(argv[0], argv[0], "-server", dirname, NULL);
ret = 1;

View File

@ -161,7 +161,9 @@ afstest_StopServer(pid_t serverPid)
kill(serverPid, SIGTERM);
waitpid(serverPid, &status, 0);
if (waitpid(serverPid, &status, 0) < 0) {
sysbail("waitpid");
}
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
fprintf(stderr, "Server died exited on signal %d\n", WTERMSIG(status));