summaryrefslogtreecommitdiff
path: root/MenuApplets/ResourceGraph
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-06-28 13:40:10 -0400
committerAndreas Kling <kling@serenityos.org>2020-06-29 12:04:27 +0200
commit12cbc4ad0d57b7f403e0a27b491b098f1431a283 (patch)
treeefe3ef1bb3555c24b3173bbfad4d97c503e3f585 /MenuApplets/ResourceGraph
parent301ac3c7e5d99f32ac9a70b51844ad7ce8c9d563 (diff)
downloadserenity-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 'MenuApplets/ResourceGraph')
-rw-r--r--MenuApplets/ResourceGraph/main.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/MenuApplets/ResourceGraph/main.cpp b/MenuApplets/ResourceGraph/main.cpp
index 2bea1acabc..775c50a940 100644
--- a/MenuApplets/ResourceGraph/main.cpp
+++ b/MenuApplets/ResourceGraph/main.cpp
@@ -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)