| 786 | } |
| 787 | #elif defined(__APPLE__) |
| 788 | static bool bootstrap_darwin_spawn_state_init(posix_spawn_file_actions_t *actions, |
| 789 | posix_spawnattr_t *attributes) { |
| 790 | if (posix_spawn_file_actions_init(actions) != 0) { |
| 791 | return false; |
| 792 | } |
| 793 | bool actions_ready = |
| 794 | posix_spawn_file_actions_addopen(actions, STDIN_FILENO, "/dev/null", O_RDWR, 0) == 0 && |
| 795 | posix_spawn_file_actions_addopen(actions, STDOUT_FILENO, "/dev/null", O_RDWR, 0) == 0 && |
| 796 | posix_spawn_file_actions_addopen(actions, STDERR_FILENO, "/dev/null", O_RDWR, 0) == 0; |
| 797 | if (!actions_ready) { |
| 798 | (void)posix_spawn_file_actions_destroy(actions); |
| 799 | return false; |
| 800 | } |
| 801 | if (posix_spawnattr_init(attributes) != 0) { |
| 802 | (void)posix_spawn_file_actions_destroy(actions); |
| 803 | return false; |
| 804 | } |
| 805 | sigset_t empty; |
| 806 | (void)sigemptyset(&empty); |
| 807 | short flags = POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSID | POSIX_SPAWN_CLOEXEC_DEFAULT; |
| 808 | if (posix_spawnattr_setsigmask(attributes, &empty) != 0 || |
| 809 | posix_spawnattr_setflags(attributes, flags) != 0) { |
| 810 | (void)posix_spawnattr_destroy(attributes); |
| 811 | (void)posix_spawn_file_actions_destroy(actions); |
| 812 | return false; |
| 813 | } |
| 814 | return true; |
| 815 | } |
| 816 | |
| 817 | typedef struct { |
| 818 | pid_t pid; |
no outgoing calls
no test coverage detected