mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibCore: Get the environment in Core::Process::spawn() on macOS
This is copied over from ladybird, but putting it here makes this more reusable.
This commit is contained in:
parent
3feddbf9da
commit
cd7459d608
Notes:
sideshowbarker
2024-07-16 22:25:28 +09:00
Author: https://github.com/MacDue
Commit: cd7459d608
Pull-request: https://github.com/SerenityOS/serenity/pull/17840
Reviewed-by: https://github.com/LucasChollet
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
1 changed files with 15 additions and 3 deletions
|
@ -21,7 +21,19 @@
|
|||
# include <syscall.h>
|
||||
#endif
|
||||
|
||||
extern char** environ;
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <crt_externs.h>
|
||||
#endif
|
||||
|
||||
static char** environment()
|
||||
{
|
||||
#if defined(AK_OS_MACOS)
|
||||
return *_NSGetEnviron();
|
||||
#else
|
||||
extern char** environ;
|
||||
return environ;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
@ -65,11 +77,11 @@ struct ArgvList {
|
|||
if (!m_working_directory.is_empty())
|
||||
posix_spawn_file_actions_addchdir(&spawn_actions, m_working_directory.characters());
|
||||
|
||||
auto pid = TRY(System::posix_spawn(m_path.view(), &spawn_actions, nullptr, const_cast<char**>(get().data()), environ));
|
||||
auto pid = TRY(System::posix_spawn(m_path.view(), &spawn_actions, nullptr, const_cast<char**>(get().data()), environment()));
|
||||
if (keep_as_child == Process::KeepAsChild::No)
|
||||
TRY(System::disown(pid));
|
||||
#else
|
||||
auto pid = TRY(System::posix_spawn(m_path.view(), nullptr, nullptr, const_cast<char**>(get().data()), environ));
|
||||
auto pid = TRY(System::posix_spawn(m_path.view(), nullptr, nullptr, const_cast<char**>(get().data()), environment()));
|
||||
// FIXME: Support keep_as_child outside Serenity.
|
||||
(void)keep_as_child;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue