mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +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:
parent
59e87cc998
commit
0eb7d1e05c
1 changed files with 7 additions and 4 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue