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

FileManager: Improve error handling when posix_spawn() fails

Previously we'd try to disown() the newly created process even if
posix_spawn() had failed.
This commit is contained in:
Gunnar Beutner 2022-11-04 08:10:42 +01:00 committed by Andreas Kling
parent 59e87cc998
commit 0eb7d1e05c

View file

@ -507,15 +507,18 @@ void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler)
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, &spawn_attributes, const_cast<char**>(argv), environ);
if (disown(child) < 0)
errno = posix_spawn(&child, launcher_handler.details().executable.characters(), &spawn_actions, &spawn_attributes, const_cast<char**>(argv), environ);
if (errno) {
perror("posix_spawn");
} else if (disown(child) < 0) {
perror("disown");
}
posix_spawn_file_actions_destroy(&spawn_actions);
} 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, &spawn_attributes, const_cast<char**>(argv), environ);
if ((errno = posix_spawn(&child, launcher_handler.details().executable.characters(), nullptr, &spawn_attributes, const_cast<char**>(argv), environ)))
continue;
if (disown(child) < 0)
perror("disown");
}