| 1192 | } |
| 1193 | #elif defined(__APPLE__) |
| 1194 | static bool bootstrap_darwin_spawn_state_init(posix_spawn_file_actions_t *actions, |
| 1195 | posix_spawnattr_t *attributes) { |
| 1196 | if (posix_spawn_file_actions_init(actions) != 0) { |
| 1197 | return false; |
| 1198 | } |
| 1199 | bool actions_ready = |
| 1200 | posix_spawn_file_actions_addopen(actions, STDIN_FILENO, "/dev/null", O_RDWR, 0) == 0 && |
| 1201 | posix_spawn_file_actions_addopen(actions, STDOUT_FILENO, "/dev/null", O_RDWR, 0) == 0 && |
| 1202 | posix_spawn_file_actions_addopen(actions, STDERR_FILENO, "/dev/null", O_RDWR, 0) == 0; |
| 1203 | if (!actions_ready) { |
| 1204 | (void)posix_spawn_file_actions_destroy(actions); |
| 1205 | return false; |
| 1206 | } |
| 1207 | if (posix_spawnattr_init(attributes) != 0) { |
| 1208 | (void)posix_spawn_file_actions_destroy(actions); |
| 1209 | return false; |
| 1210 | } |
| 1211 | sigset_t empty; |
| 1212 | (void)sigemptyset(&empty); |
| 1213 | short flags = POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSID | POSIX_SPAWN_CLOEXEC_DEFAULT; |
| 1214 | if (posix_spawnattr_setsigmask(attributes, &empty) != 0 || |
| 1215 | posix_spawnattr_setflags(attributes, flags) != 0) { |
| 1216 | (void)posix_spawnattr_destroy(attributes); |
| 1217 | (void)posix_spawn_file_actions_destroy(actions); |
| 1218 | return false; |
| 1219 | } |
| 1220 | return true; |
| 1221 | } |
| 1222 | |
| 1223 | typedef struct { |
| 1224 | pid_t pid; |
no outgoing calls
no test coverage detected