--- a/src/subprocess-posix.cc +++ b/src/subprocess-posix.cc @@ -72,6 +72,45 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { SetCloseOnExec(fd_); } +#if defined(__redox__) + pid_ = fork(); + if (pid_ < 0) + Fatal("fork: %s", strerror(errno)); + if (pid_ == 0) { + if (sigprocmask(SIG_SETMASK, &set->old_mask_, 0) < 0) { + perror("ninja: sigprocmask"); + _exit(1); + } + if (!use_console_) { + if (setpgid(0, 0) < 0) { + perror("ninja: setpgid"); + _exit(1); + } + int devnull = open("/dev/null", O_RDONLY); + if (devnull < 0) { + perror("ninja: open /dev/null"); + _exit(1); + } + if (dup2(devnull, 0) < 0 || dup2(subproc_stdout_fd, 1) < 0 || + dup2(subproc_stdout_fd, 2) < 0) { + perror("ninja: dup2"); + _exit(1); + } + close(devnull); + close(fd_); + close(subproc_stdout_fd); + } + + const char* spawned_args[] = { "/bin/sh", "-c", command.c_str(), NULL }; + execve("/bin/sh", const_cast(spawned_args), environ); + perror("ninja: execve /bin/sh"); + _exit(127); + } + + if (!use_console_) + close(subproc_stdout_fd); + return true; +#else posix_spawn_file_actions_t action; int err = posix_spawn_file_actions_init(&action); if (err != 0) @@ -145,6 +184,7 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { if (!use_console_) close(subproc_stdout_fd); return true; +#endif } void Subprocess::OnPipeReady() { --- a/src/util.cc +++ b/src/util.cc @@ -973,7 +973,7 @@ double GetLoadAverage() { return -0.0f; return 1.0 / (1 << SI_LOAD_SHIFT) * si.loads[0]; } -#elif defined(__HAIKU__) +#elif defined(__HAIKU__) || defined(__redox__) double GetLoadAverage() { return -0.0f; }