Applets: Use spawn_or_show_error() for common spawn pattern

This commit is contained in:
MacDue 2022-05-26 23:30:32 +01:00 committed by Linus Groh
parent 5fd5a03d1f
commit 5aad6a4378

View file

@ -12,6 +12,7 @@
#include <LibGUI/ImageWidget.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Notification.h>
#include <LibGUI/Process.h>
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>
#include <LibMain/Main.h>
@ -49,17 +50,7 @@ private:
{
if (event.button() != GUI::MouseButton::Primary)
return;
pid_t child_pid;
char const* argv[] = { "SystemMonitor", "-t", "network", nullptr };
if ((errno = posix_spawn(&child_pid, "/bin/SystemMonitor", nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
return;
}
if (disown(child_pid) < 0)
perror("disown");
GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor", Array { "-t", "network" });
}
virtual void update_widget()