1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:08:12 +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

@ -44,6 +44,7 @@
#include <LibGfx/Bitmap.h>
#include <LibGfx/Palette.h>
#include <LibGfx/Rect.h>
#include <spawn.h>
#include <stdio.h>
#include <string.h>
@ -110,11 +111,10 @@ int main(int argc, char** argv)
widget.load_from_file(url.path());
}
pid_t child;
for (size_t i = 1; i < urls.size(); ++i) {
if (fork() == 0) {
execl("/bin/QuickShow", "/bin/QuickShow", urls[i].path().characters(), nullptr);
ASSERT_NOT_REACHED();
}
const char* argv[] = { "/bin/QuickShow", urls[i].path().characters(), nullptr };
posix_spawn(&child, "/bin/QuickShow", nullptr, nullptr, const_cast<char**>(argv), environ);
}
}
};