1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:17:35 +00:00

FileManager: Disown spawned processes

This commit is contained in:
Andreas Kling 2020-08-04 14:09:42 +02:00
parent edefcc7f3a
commit 46ab006c58

View file

@ -57,6 +57,7 @@
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibGfx/Palette.h>
#include <serenity.h>
#include <signal.h>
#include <spawn.h>
#include <stdio.h>
@ -382,7 +383,12 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
posix_spawn_file_actions_addchdir(&spawn_actions, directory_view.path().characters());
pid_t pid;
const char* argv[] = { "Terminal", nullptr };
posix_spawn(&pid, "/bin/Terminal", &spawn_actions, nullptr, const_cast<char**>(argv), environ);
if ((errno = posix_spawn(&pid, "/bin/Terminal", &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
} else {
if (disown(pid) < 0)
perror("disown");
}
posix_spawn_file_actions_destroy(&spawn_actions);
});
@ -802,10 +808,14 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
if (launcher_handler.details().launcher_type == Desktop::Launcher::LauncherType::Application) {
const char* argv[] = { launcher_handler.details().name.characters(), nullptr };
posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, nullptr, const_cast<char**>(argv), environ);
if (disown(child) < 0)
perror("disown");
} else {
for (auto& path : selected_file_paths()) {
const char* argv[] = { launcher_handler.details().name.characters(), path.characters(), nullptr };
posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, nullptr, const_cast<char**>(argv), environ);
if (disown(child) < 0)
perror("disown");
}
}
};