1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 18:05:07 +00:00

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.
This commit is contained in:
Nico Weber 2020-06-28 13:40:10 -04:00 committed by Andreas Kling
parent 301ac3c7e5
commit 12cbc4ad0d
11 changed files with 65 additions and 101 deletions

View file

@ -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;