[macOS] Pass parent environment to spawned app instances

(cherry picked from commit 2df02c8463)
This commit is contained in:
arthurmtro
2026-03-11 21:04:08 +01:00
committed by Thaddeus Crews
parent 8402ed6435
commit 46fb015202
+6 -1
View File
@@ -813,6 +813,7 @@ Error OS_MacOS::create_process(const String &p_path, const List<String> &p_argum
NSWorkspaceOpenConfiguration *configuration = [[NSWorkspaceOpenConfiguration alloc] init];
[configuration setArguments:arguments];
[configuration setCreatesNewApplicationInstance:YES];
[configuration setEnvironment:[[NSProcessInfo processInfo] environment]];
__block dispatch_semaphore_t lock = dispatch_semaphore_create(0);
__block Error err = ERR_TIMEOUT;
__block pid_t pid = 0;
@@ -842,7 +843,11 @@ Error OS_MacOS::create_process(const String &p_path, const List<String> &p_argum
} else {
Error err = ERR_TIMEOUT;
NSError *error = nullptr;
NSRunningApplication *app = [[NSWorkspace sharedWorkspace] launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];
NSDictionary *config = @{
NSWorkspaceLaunchConfigurationArguments : arguments,
NSWorkspaceLaunchConfigurationEnvironment : [[NSProcessInfo processInfo] environment]
};
NSRunningApplication *app = [[NSWorkspace sharedWorkspace] launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:config error:&error];
if (error) {
err = ERR_CANT_FORK;
NSLog(@"Failed to execute: %@", error.localizedDescription);