mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
Ladybird/WebDriver: Retrieve process environment in an OS-dependent way
This commit is contained in:
parent
e5192073d9
commit
03294b0177
Notes:
sideshowbarker
2024-07-17 02:37:56 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/03294b0177 Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/linusg
1 changed files with 17 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
#define AK_DONT_REPLACE_STD
|
||||
|
||||
#include "../Utilities.h"
|
||||
#include <AK/Platform.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
|
@ -16,8 +17,22 @@
|
|||
#include <LibMain/Main.h>
|
||||
#include <WebDriver/Client.h>
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <crt_externs.h>
|
||||
#endif
|
||||
|
||||
extern DeprecatedString s_serenity_resource_root;
|
||||
|
||||
static char** environment()
|
||||
{
|
||||
#if defined(AK_OS_MACOS)
|
||||
return *_NSGetEnviron();
|
||||
#else
|
||||
extern char** environ;
|
||||
return environ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
|
||||
{
|
||||
char const* argv[] = {
|
||||
|
@ -27,7 +42,7 @@ static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
|
|||
nullptr,
|
||||
};
|
||||
|
||||
return Core::System::posix_spawn("./ladybird"sv, nullptr, nullptr, const_cast<char**>(argv), environ);
|
||||
return Core::System::posix_spawn("./ladybird"sv, nullptr, nullptr, const_cast<char**>(argv), environment());
|
||||
}
|
||||
|
||||
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
|
|||
nullptr,
|
||||
};
|
||||
|
||||
return Core::System::posix_spawn("./_deps/lagom-build/headless-browser"sv, nullptr, nullptr, const_cast<char**>(argv), environ);
|
||||
return Core::System::posix_spawn("./_deps/lagom-build/headless-browser"sv, nullptr, nullptr, const_cast<char**>(argv), environment());
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
|
Loading…
Add table
Reference in a new issue