mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
HackStudio: Use Core::System APIs where possible
This commit is contained in:
parent
16543a1918
commit
336b8ed80b
4 changed files with 23 additions and 15 deletions
|
@ -93,18 +93,25 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
static bool make_is_available()
|
||||
{
|
||||
pid_t pid;
|
||||
char const* argv[] = { "make", "--version", nullptr };
|
||||
posix_spawn_file_actions_t action;
|
||||
posix_spawn_file_actions_init(&action);
|
||||
posix_spawn_file_actions_addopen(&action, STDOUT_FILENO, "/dev/null", O_WRONLY, 0);
|
||||
|
||||
if ((errno = posix_spawnp(&pid, "make", &action, nullptr, const_cast<char**>(argv), environ))) {
|
||||
perror("posix_spawn");
|
||||
auto maybe_pid = Core::System::posix_spawnp("make"sv, &action, nullptr, const_cast<char**>(argv), environ);
|
||||
if (maybe_pid.is_error()) {
|
||||
warnln("Failed to posix_spawn make: {}", maybe_pid.release_error());
|
||||
return false;
|
||||
}
|
||||
int wstatus;
|
||||
waitpid(pid, &wstatus, 0);
|
||||
pid_t pid = maybe_pid.release_value();
|
||||
|
||||
auto waitpid_result = Core::System::waitpid(pid, 0);
|
||||
if (waitpid_result.is_error()) {
|
||||
warnln("Failed to waitpid for make: {}", waitpid_result.release_error());
|
||||
return false;
|
||||
}
|
||||
|
||||
int wstatus = waitpid_result.value().status;
|
||||
posix_spawn_file_actions_destroy(&action);
|
||||
return WEXITSTATUS(wstatus) == 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue