mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 07:20:11 +00:00
5cfea96b23
The StopVLServer function can be used to stop any server for which we know the pid. So, rename it as afstest_StopServer to make this apparent. Change-Id: Ia5973342e81dc15a698e84e69b314cd6157831f7 Reviewed-on: http://gerrit.openafs.org/7258 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org>
66 lines
1.3 KiB
C
66 lines
1.3 KiB
C
#include <afsconfig.h>
|
|
#include <afs/param.h>
|
|
|
|
#include <roken.h>
|
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
#include <sys/wait.h>
|
|
#endif
|
|
|
|
#include "common.h"
|
|
|
|
/* Start up the VLserver, using the configuration in dirname, and putting our
|
|
* logs there too.
|
|
*/
|
|
|
|
int
|
|
afstest_StartVLServer(char *dirname, pid_t *serverPid)
|
|
{
|
|
pid_t pid;
|
|
|
|
pid = fork();
|
|
if (pid == -1) {
|
|
exit(1);
|
|
/* Argggggghhhhh */
|
|
} else if (pid == 0) {
|
|
char *binPath, *logPath, *dbPath, *build;
|
|
|
|
/* Child */
|
|
build = getenv("BUILD");
|
|
|
|
if (build == NULL)
|
|
build = "..";
|
|
|
|
asprintf(&binPath, "%s/../src/tvlserver/vlserver", build);
|
|
asprintf(&logPath, "%s/VLLog", dirname);
|
|
asprintf(&dbPath, "%s/vldb", dirname);
|
|
execl(binPath, "vlserver",
|
|
"-logfile", logPath, "-database", dbPath, "-config", dirname, NULL);
|
|
fprintf(stderr, "Running %s failed\n", binPath);
|
|
exit(1);
|
|
}
|
|
*serverPid = pid;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
afstest_StopServer(pid_t serverPid)
|
|
{
|
|
int status;
|
|
|
|
kill(serverPid, SIGTERM);
|
|
|
|
waitpid(serverPid, &status, 0);
|
|
|
|
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
|
|
fprintf(stderr, "Server died exited on signal %d\n", WTERMSIG(status));
|
|
return -1;
|
|
}
|
|
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
|
|
fprintf(stderr, "Server exited with code %d\n", WEXITSTATUS(status));
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|