Skip to content
This repository was archived by the owner on Dec 25, 2022. It is now read-only.

Commit 94e2442

Browse files
trflynn89linusg
authored andcommitted
WebDriver: Retrieve the process environment in an OS-dependent manner
1 parent 1dee21e commit 94e2442

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

WebDriver/main.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define AK_DONT_REPLACE_STD
88

99
#include "../Utilities.h"
10+
#include <AK/Platform.h>
1011
#include <LibCore/ArgsParser.h>
1112
#include <LibCore/Directory.h>
1213
#include <LibCore/EventLoop.h>
@@ -16,8 +17,22 @@
1617
#include <LibMain/Main.h>
1718
#include <WebDriver/Client.h>
1819

20+
#if defined(AK_OS_MACOS)
21+
# include <crt_externs.h>
22+
#endif
23+
1924
extern DeprecatedString s_serenity_resource_root;
2025

26+
static char** environment()
27+
{
28+
#if defined(AK_OS_MACOS)
29+
return *_NSGetEnviron();
30+
#else
31+
extern char** environ;
32+
return environ;
33+
#endif
34+
}
35+
2136
static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
2237
{
2338
char const* argv[] = {
@@ -27,7 +42,7 @@ static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
2742
nullptr,
2843
};
2944

30-
return Core::System::posix_spawn("./ladybird"sv, nullptr, nullptr, const_cast<char**>(argv), environ);
45+
return Core::System::posix_spawn("./ladybird"sv, nullptr, nullptr, const_cast<char**>(argv), environment());
3146
}
3247

3348
static ErrorOr<pid_t> launch_headless_browser(DeprecatedString const& socket_path)
@@ -50,7 +65,7 @@ static ErrorOr<pid_t> launch_headless_browser(DeprecatedString const& socket_pat
5065
nullptr,
5166
};
5267

53-
return Core::System::posix_spawn("./_deps/lagom-build/headless-browser"sv, nullptr, nullptr, const_cast<char**>(argv), environ);
68+
return Core::System::posix_spawn("./_deps/lagom-build/headless-browser"sv, nullptr, nullptr, const_cast<char**>(argv), environment());
5469
}
5570

5671
ErrorOr<int> serenity_main(Main::Arguments arguments)

0 commit comments

Comments
 (0)