summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-08-02 15:21:43 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-03 09:12:33 +0200
commit35cc5b9873a4c7b87308afe259f8fcca189426d1 (patch)
tree551bbfaf8c4a2c6b8581783f253bb6e3aa984693 /Userland
parent49ae73022c9f187e1d47fe7b1576ac3523b17199 (diff)
downloadserenity-35cc5b9873a4c7b87308afe259f8fcca189426d1.zip
FileManager: Set chdir to the current path when opening applications
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/FileManager/DirectoryView.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp
index da49c20ad0..66739bd3ca 100644
--- a/Userland/Applications/FileManager/DirectoryView.cpp
+++ b/Userland/Applications/FileManager/DirectoryView.cpp
@@ -448,10 +448,16 @@ void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler)
{
pid_t child;
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(), nullptr, nullptr, const_cast<char**>(argv), environ);
+ posix_spawn(&child, launcher_handler.details().executable.characters(), &spawn_actions, nullptr, const_cast<char**>(argv), environ);
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 };