mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 17:58: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:
parent
301ac3c7e5
commit
12cbc4ad0d
11 changed files with 65 additions and 101 deletions
|
@ -47,6 +47,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <spawn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -257,10 +258,9 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& app_menu = menubar->add_menu("Terminal");
|
||||
app_menu.add_action(GUI::Action::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
|
||||
if (!fork()) {
|
||||
execl("/bin/Terminal", "Terminal", nullptr);
|
||||
exit(1);
|
||||
}
|
||||
pid_t child;
|
||||
const char* argv[] = { "Terminal", nullptr };
|
||||
posix_spawn(&child, "/bin/Terminal", nullptr, nullptr, const_cast<char**>(argv), environ);
|
||||
}));
|
||||
app_menu.add_action(GUI::Action::create("Settings...", Gfx::Bitmap::load_from_file("/res/icons/gear16.png"),
|
||||
[&](const GUI::Action&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue