| 937 | } |
| 938 | |
| 939 | static void bootstrap_daemon_grandchild(const cbm_daemon_bootstrap_launch_spec_t *spec) { |
| 940 | (void)umask(077); |
| 941 | sigset_t empty; |
| 942 | (void)sigemptyset(&empty); |
| 943 | (void)sigprocmask(SIG_SETMASK, &empty, NULL); |
| 944 | int null_fd = open("/dev/null", O_RDWR); |
| 945 | if (null_fd < 0 || dup2(null_fd, STDIN_FILENO) < 0 || dup2(null_fd, STDOUT_FILENO) < 0 || |
| 946 | dup2(null_fd, STDERR_FILENO) < 0) { |
| 947 | _exit(127); |
| 948 | } |
| 949 | if (null_fd > STDERR_FILENO) { |
| 950 | (void)close(null_fd); |
| 951 | } |
| 952 | bootstrap_child_close_fds(); |
| 953 | execv(spec->executable_path, (char *const *)spec->argv); |
| 954 | _exit(127); |
| 955 | } |
| 956 | |
| 957 | static bool bootstrap_production_spawn(void *context, |
| 958 | const cbm_daemon_bootstrap_launch_spec_t *spec) { |
no test coverage detected