mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibCore: Add System::environment
Move this from an internal function of Core::Process so that it can be used elsewhere.
This commit is contained in:
parent
806808f406
commit
cb920b23cc
Notes:
sideshowbarker
2024-07-17 03:03:44 +09:00
Author: https://github.com/shannonbooth
Commit: cb920b23cc
Pull-request: https://github.com/SerenityOS/serenity/pull/19994
Reviewed-by: https://github.com/AtkinsSJ
3 changed files with 16 additions and 16 deletions
|
@ -21,20 +21,6 @@
|
|||
# include <syscall.h>
|
||||
#endif
|
||||
|
||||
#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 {
|
||||
|
||||
struct ArgvList {
|
||||
|
@ -77,11 +63,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()), environment()));
|
||||
auto pid = TRY(System::posix_spawn(m_path.view(), &spawn_actions, nullptr, const_cast<char**>(get().data()), System::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()), environment()));
|
||||
auto pid = TRY(System::posix_spawn(m_path.view(), nullptr, nullptr, const_cast<char**>(get().data()), System::environment()));
|
||||
// FIXME: Support keep_as_child outside Serenity.
|
||||
(void)keep_as_child;
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,10 @@ static int memfd_create(char const* name, unsigned int flags)
|
|||
#endif
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <crt_externs.h>
|
||||
# include <sys/mman.h>
|
||||
#else
|
||||
extern char** environ;
|
||||
#endif
|
||||
|
||||
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
||||
|
@ -1714,4 +1717,13 @@ ErrorOr<String> resolve_executable_from_environment(StringView filename, int fla
|
|||
return Error::from_errno(ENOENT);
|
||||
}
|
||||
|
||||
char** environment()
|
||||
{
|
||||
#if defined(AK_OS_MACOS)
|
||||
return *_NSGetEnviron();
|
||||
#else
|
||||
return environ;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -271,4 +271,6 @@ ErrorOr<void> posix_fallocate(int fd, off_t offset, off_t length);
|
|||
|
||||
ErrorOr<String> resolve_executable_from_environment(StringView filename, int flags = 0);
|
||||
|
||||
char** environment();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue