mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:31:58 +00:00
[vm] Remove ProcessStarter on iOS
Bug: https://github.com/dart-lang/sdk/issues/45452 Fixes: https://github.com/dart-lang/sdk/issues/45452 Change-Id: I85fe624b64b8fac1e0a24a817f197c715dab3e27 TEST=CI and manual testing on iPhone Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193525 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
This commit is contained in:
parent
583da435e9
commit
5f7a3910fe
|
@ -37,6 +37,9 @@ int Process::global_exit_code_ = 0;
|
|||
Mutex* Process::global_exit_code_mutex_ = nullptr;
|
||||
Process::ExitHook Process::exit_hook_ = nullptr;
|
||||
|
||||
// Spawning new processes isn't supported on iOS.
|
||||
#if !defined(DART_HOST_OS_IOS)
|
||||
|
||||
// ProcessInfo is used to map a process id to the file descriptor for
|
||||
// the pipe used to communicate the exit code of the process to Dart.
|
||||
// ProcessInfo objects are kept in the static singly-linked
|
||||
|
@ -468,14 +471,12 @@ class ProcessStarter {
|
|||
ReportChildError();
|
||||
}
|
||||
|
||||
#if !DART_HOST_OS_IOS
|
||||
if (program_environment_ != nullptr) {
|
||||
// On MacOS you have to do a bit of magic to get to the
|
||||
// environment strings.
|
||||
char*** environ = _NSGetEnviron();
|
||||
*environ = program_environment_;
|
||||
}
|
||||
#endif
|
||||
|
||||
execvp(path_, const_cast<char* const*>(program_arguments_));
|
||||
ReportChildError();
|
||||
|
@ -521,14 +522,13 @@ class ProcessStarter {
|
|||
(TEMP_FAILURE_RETRY(chdir(working_directory_)) == -1)) {
|
||||
ReportChildError();
|
||||
}
|
||||
#if !DART_HOST_OS_IOS
|
||||
|
||||
if (program_environment_ != nullptr) {
|
||||
// On MacOS you have to do a bit of magic to get to the
|
||||
// environment strings.
|
||||
char*** environ = _NSGetEnviron();
|
||||
*environ = program_environment_;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Report the final PID and do the exec.
|
||||
ReportPid(getpid()); // getpid cannot fail.
|
||||
|
@ -760,6 +760,7 @@ class ProcessStarter {
|
|||
DISALLOW_ALLOCATION();
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(ProcessStarter);
|
||||
};
|
||||
#endif // !defined(DART_HOST_OS_IOS)
|
||||
|
||||
int Process::Start(Namespace* namespc,
|
||||
const char* path,
|
||||
|
@ -775,12 +776,17 @@ int Process::Start(Namespace* namespc,
|
|||
intptr_t* id,
|
||||
intptr_t* exit_event,
|
||||
char** os_error_message) {
|
||||
#if defined(DART_HOST_OS_IOS)
|
||||
return EPERM;
|
||||
#else // defined(DART_HOST_OS_IOS)
|
||||
ProcessStarter starter(path, arguments, arguments_length, working_directory,
|
||||
environment, environment_length, mode, in, out, err,
|
||||
id, exit_event, os_error_message);
|
||||
return starter.Start();
|
||||
#endif // defined(DART_HOST_OS_IOS)
|
||||
}
|
||||
|
||||
#if !defined(DART_HOST_OS_IOS)
|
||||
static bool CloseProcessBuffers(struct pollfd* fds, int alive) {
|
||||
int e = errno;
|
||||
for (int i = 0; i < alive; i++) {
|
||||
|
@ -789,6 +795,7 @@ static bool CloseProcessBuffers(struct pollfd* fds, int alive) {
|
|||
errno = e;
|
||||
return false;
|
||||
}
|
||||
#endif // !defined(DART_HOST_OS_IOS)
|
||||
|
||||
bool Process::Wait(intptr_t pid,
|
||||
intptr_t in,
|
||||
|
@ -796,6 +803,9 @@ bool Process::Wait(intptr_t pid,
|
|||
intptr_t err,
|
||||
intptr_t exit_event,
|
||||
ProcessResult* result) {
|
||||
#if defined(DART_HOST_OS_IOS)
|
||||
return false;
|
||||
#else // defined(DART_HOST_OS_IOS)
|
||||
// Close input to the process right away.
|
||||
close(in);
|
||||
|
||||
|
@ -887,6 +897,7 @@ bool Process::Wait(intptr_t pid,
|
|||
result->set_exit_code(exit_code);
|
||||
|
||||
return true;
|
||||
#endif // defined(DART_HOST_OS_IOS)
|
||||
}
|
||||
|
||||
static int SignalMap(intptr_t id) {
|
||||
|
@ -954,11 +965,17 @@ static int SignalMap(intptr_t id) {
|
|||
}
|
||||
|
||||
bool Process::Kill(intptr_t id, int signal) {
|
||||
#if defined(DART_HOST_OS_IOS)
|
||||
return false;
|
||||
#else // defined(DART_HOST_OS_IOS)
|
||||
return (TEMP_FAILURE_RETRY(kill(id, SignalMap(signal))) != -1);
|
||||
#endif // defined(DART_HOST_OS_IOS)
|
||||
}
|
||||
|
||||
void Process::TerminateExitCodeHandler() {
|
||||
#if !defined(DART_HOST_OS_IOS)
|
||||
ExitCodeHandler::TerminateExitCodeThread();
|
||||
#endif // !defined(DART_HOST_OS_IOS)
|
||||
}
|
||||
|
||||
intptr_t Process::CurrentProcessId() {
|
||||
|
@ -1143,6 +1160,7 @@ void Process::ClearSignalHandlerByFd(intptr_t fd, Dart_Port port) {
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(DART_HOST_OS_IOS)
|
||||
void ProcessInfoList::Init() {
|
||||
active_processes_ = nullptr;
|
||||
ASSERT(ProcessInfoList::mutex_ == nullptr);
|
||||
|
@ -1168,10 +1186,13 @@ void ExitCodeHandler::Cleanup() {
|
|||
delete ExitCodeHandler::monitor_;
|
||||
ExitCodeHandler::monitor_ = nullptr;
|
||||
}
|
||||
#endif // !defined(DART_HOST_OS_IOS)
|
||||
|
||||
void Process::Init() {
|
||||
#if !defined(DART_HOST_OS_IOS)
|
||||
ExitCodeHandler::Init();
|
||||
ProcessInfoList::Init();
|
||||
#endif // !defined(DART_HOST_OS_IOS)
|
||||
|
||||
ASSERT(signal_mutex == nullptr);
|
||||
signal_mutex = new Mutex();
|
||||
|
@ -1192,8 +1213,10 @@ void Process::Cleanup() {
|
|||
delete Process::global_exit_code_mutex_;
|
||||
Process::global_exit_code_mutex_ = nullptr;
|
||||
|
||||
#if !defined(DART_HOST_OS_IOS)
|
||||
ProcessInfoList::Cleanup();
|
||||
ExitCodeHandler::Cleanup();
|
||||
#endif // !defined(DART_HOST_OS_IOS)
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
|
|
Loading…
Reference in a new issue