summaryrefslogtreecommitdiff
path: root/Services/SystemMenu/main.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-04 14:23:39 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-04 18:17:16 +0200
commit6e1cb2bae88c9d2ce97bf447b7180fa51c56dcf4 (patch)
treea8a162d19cde5e99911ffb733780925c71a5a17b /Services/SystemMenu/main.cpp
parentcf624550e56e2947cb5361cc57c1e5fd9d103b57 (diff)
downloadserenity-6e1cb2bae88c9d2ce97bf447b7180fa51c56dcf4.zip
SystemMenu: Disown child processes after spawning
Diffstat (limited to 'Services/SystemMenu/main.cpp')
-rw-r--r--Services/SystemMenu/main.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/Services/SystemMenu/main.cpp b/Services/SystemMenu/main.cpp
index 8a6ad8aa75..05e0eed0f2 100644
--- a/Services/SystemMenu/main.cpp
+++ b/Services/SystemMenu/main.cpp
@@ -215,7 +215,12 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
system_menu->add_action(GUI::Action::create("About...", Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"), [](auto&) {
pid_t child_pid;
const char* argv[] = { "/bin/About", nullptr };
- posix_spawn(&child_pid, "/bin/About", nullptr, nullptr, const_cast<char**>(argv), environ);
+ if ((errno = posix_spawn(&child_pid, "/bin/About", nullptr, nullptr, const_cast<char**>(argv), environ))) {
+ perror("posix_spawn");
+ } else {
+ if (disown(child_pid) < 0)
+ perror("disown");
+ }
}));
system_menu->add_separator();
system_menu->add_action(GUI::Action::create("Exit...", Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"), [](auto&) {
@@ -225,7 +230,12 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
return;
pid_t child_pid;
- posix_spawn(&child_pid, command[0], nullptr, nullptr, const_cast<char**>(command.data()), environ);
+ if ((errno = posix_spawn(&child_pid, command[0], nullptr, nullptr, const_cast<char**>(command.data()), environ))) {
+ perror("posix_spawn");
+ } else {
+ if (disown(child_pid) < 0)
+ perror("disown");
+ }
}));
return system_menu;