mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 18:23:39 +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
Notes:
sideshowbarker
2024-07-19 05:19:53 +09:00
Author: https://github.com/nico
Commit: 12cbc4ad0d
11 changed files with 65 additions and 101 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <spawn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
enum class GraphType {
|
||||
|
@ -106,14 +107,10 @@ private:
|
|||
{
|
||||
if (event.button() != GUI::MouseButton::Left)
|
||||
return;
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fork");
|
||||
} else if (pid == 0) {
|
||||
execl("/bin/SystemMonitor", "SystemMonitor", nullptr);
|
||||
perror("execl");
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
pid_t child_pid;
|
||||
const char* argv[] = { "SystemMonitor", nullptr };
|
||||
if ((errno = posix_spawn(&child_pid, "/bin/SystemMonitor", nullptr, nullptr, const_cast<char**>(argv), environ)))
|
||||
perror("posix_spawn");
|
||||
}
|
||||
|
||||
static void get_cpu_usage(unsigned& busy, unsigned& idle)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue