diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-04 14:23:39 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-04 18:17:16 +0200 |
commit | 6e1cb2bae88c9d2ce97bf447b7180fa51c56dcf4 (patch) | |
tree | a8a162d19cde5e99911ffb733780925c71a5a17b /Services/SystemMenu/main.cpp | |
parent | cf624550e56e2947cb5361cc57c1e5fd9d103b57 (diff) | |
download | serenity-6e1cb2bae88c9d2ce97bf447b7180fa51c56dcf4.zip |
SystemMenu: Disown child processes after spawning
Diffstat (limited to 'Services/SystemMenu/main.cpp')
-rw-r--r-- | Services/SystemMenu/main.cpp | 14 |
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; |