diff options
author | Nico Weber <thakis@chromium.org> | 2020-06-28 13:40:10 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-29 12:04:27 +0200 |
commit | 12cbc4ad0d57b7f403e0a27b491b098f1431a283 (patch) | |
tree | efe3ef1bb3555c24b3173bbfad4d97c503e3f585 /DevTools/HackStudio | |
parent | 301ac3c7e5d99f32ac9a70b51844ad7ce8c9d563 (diff) | |
download | serenity-12cbc4ad0d57b7f403e0a27b491b098f1431a283.zip |
Everywhere: Replace some uses of fork/exec with posix_spawn
It's less code, and it's potentially more efficient once
posix_spawn is a real syscall.
Diffstat (limited to 'DevTools/HackStudio')
-rw-r--r-- | DevTools/HackStudio/main.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 81aa9ac9bd..e6357639f7 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -71,6 +71,7 @@ #include <LibThread/Lock.h> #include <LibThread/Thread.h> #include <LibVT/TerminalWidget.h> +#include <spawn.h> #include <stdio.h> #include <sys/wait.h> #include <unistd.h> @@ -766,15 +767,11 @@ void open_file(const String& filename) bool make_is_available() { - auto pid = fork(); - if (pid < 0) + pid_t pid; + const char* argv[] = { "make", "--version", nullptr }; + if ((errno = posix_spawnp(&pid, "make", nullptr, nullptr, const_cast<char**>(argv), environ))) { + perror("posix_spawn"); return false; - - if (!pid) { - int rc = execlp("make", "make", "--version", nullptr); - ASSERT(rc < 0); - perror("execl"); - exit(127); } int wstatus; |