]> git.saurik.com Git - apple/xnu.git/blob - tests/subsystem_root_path.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / subsystem_root_path.h
1 #include <unistd.h>
2 #include <spawn.h>
3 #include <sys/wait.h>
4
5 #define SUBSYSTEM_ROOT_PATH_KEY "subsystem_root_path"
6
7 #define HELPER_BEHAVIOR_NOT_SET "not_set"
8 #define HELPER_BEHAVIOR_SET "set"
9 #define HELPER_BEHAVIOR_FORK_EXEC "fork_exec"
10 #define HELPER_BEHAVIOR_SPAWN "spawn"
11
12 static int
13 _spawn_and_wait(char ** args, posix_spawnattr_t *attr)
14 {
15 int pid;
16 int status;
17
18 if (posix_spawn(&pid, args[0], NULL, attr, args, NULL)) {
19 return -1;
20 }
21 if (waitpid(pid, &status, 0) < 0) {
22 return -1;
23 }
24
25 if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)) {
26 return 0;
27 }
28
29 return -1;
30 }