mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
FileManager: Change PGID of spawned processes
Processes spawned by FileManager (e.g. through double-click) now set their PGID to that of the session leader. It allows the filemanage instance to be killed without propagating the signal to the new process.
This commit is contained in:
parent
63d06458ca
commit
6f04a3778b
Notes:
sideshowbarker
2024-07-17 09:34:16 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/6f04a3778b Pull-request: https://github.com/SerenityOS/serenity/pull/14294 Issue: https://github.com/SerenityOS/serenity/issues/5306 Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 12 additions and 2 deletions
|
@ -478,13 +478,23 @@ void DirectoryView::set_should_show_dotfiles(bool show_dotfiles)
|
|||
void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler) const
|
||||
{
|
||||
pid_t child;
|
||||
|
||||
posix_spawnattr_t spawn_attributes;
|
||||
posix_spawnattr_init(&spawn_attributes);
|
||||
|
||||
posix_spawnattr_setpgroup(&spawn_attributes, getsid(0));
|
||||
|
||||
short current_flag;
|
||||
posix_spawnattr_getflags(&spawn_attributes, ¤t_flag);
|
||||
posix_spawnattr_setflags(&spawn_attributes, static_cast<short>(current_flag | POSIX_SPAWN_SETPGROUP));
|
||||
|
||||
if (launcher_handler.details().launcher_type == Desktop::Launcher::LauncherType::Application) {
|
||||
posix_spawn_file_actions_t spawn_actions;
|
||||
posix_spawn_file_actions_init(&spawn_actions);
|
||||
posix_spawn_file_actions_addchdir(&spawn_actions, path().characters());
|
||||
|
||||
char const* argv[] = { launcher_handler.details().name.characters(), nullptr };
|
||||
posix_spawn(&child, launcher_handler.details().executable.characters(), &spawn_actions, nullptr, const_cast<char**>(argv), environ);
|
||||
posix_spawn(&child, launcher_handler.details().executable.characters(), &spawn_actions, &spawn_attributes, const_cast<char**>(argv), environ);
|
||||
if (disown(child) < 0)
|
||||
perror("disown");
|
||||
|
||||
|
@ -492,7 +502,7 @@ void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler)
|
|||
} else {
|
||||
for (auto& path : selected_file_paths()) {
|
||||
char const* argv[] = { launcher_handler.details().name.characters(), path.characters(), nullptr };
|
||||
posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, nullptr, const_cast<char**>(argv), environ);
|
||||
posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, &spawn_attributes, const_cast<char**>(argv), environ);
|
||||
if (disown(child) < 0)
|
||||
perror("disown");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue