SystemMenu: Disown child processes after spawning

This commit is contained in:
Andreas Kling 2020-08-04 14:23:39 +02:00
parent cf624550e5
commit 6e1cb2bae8
Notes: sideshowbarker 2024-07-19 04:19:11 +09:00

View file

@ -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;