diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2022-11-04 08:10:42 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-04 09:47:30 +0100 |
commit | 0eb7d1e05c2b2589047e6f3b61f41cb903fde4b9 (patch) | |
tree | 66a86132600c48641ad94c01c352909d5402927b /Userland/Applications/FileManager | |
parent | 59e87cc9985d90bca7141eb49f9d57e534b677de (diff) | |
download | serenity-0eb7d1e05c2b2589047e6f3b61f41cb903fde4b9.zip |
FileManager: Improve error handling when posix_spawn() fails
Previously we'd try to disown() the newly created process even if
posix_spawn() had failed.
Diffstat (limited to 'Userland/Applications/FileManager')
-rw-r--r-- | Userland/Applications/FileManager/DirectoryView.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 525ffb2b9b..832b36f713 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -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"); } |