mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00: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
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue