| Index: runtime/bin/process_macos.cc
|
| diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc
|
| index 582a8eae1ad14e4f1847ee9dc25038123aae2460..b59a0f094d07d6d1ce66ea661cdd29da1d6748bc 100644
|
| --- a/runtime/bin/process_macos.cc
|
| +++ b/runtime/bin/process_macos.cc
|
| @@ -12,15 +12,15 @@
|
| #if !HOST_OS_IOS
|
| #include <crt_externs.h> // NOLINT
|
| #endif
|
| -#include <errno.h> // NOLINT
|
| -#include <fcntl.h> // NOLINT
|
| +#include <errno.h> // NOLINT
|
| +#include <fcntl.h> // NOLINT
|
| #include <mach/mach.h> // NOLINT
|
| -#include <poll.h> // NOLINT
|
| -#include <signal.h> // NOLINT
|
| -#include <stdio.h> // NOLINT
|
| -#include <stdlib.h> // NOLINT
|
| -#include <string.h> // NOLINT
|
| -#include <unistd.h> // NOLINT
|
| +#include <poll.h> // NOLINT
|
| +#include <signal.h> // NOLINT
|
| +#include <stdio.h> // NOLINT
|
| +#include <stdlib.h> // NOLINT
|
| +#include <string.h> // NOLINT
|
| +#include <unistd.h> // NOLINT
|
|
|
| #include "bin/dartutils.h"
|
| #include "bin/fdutils.h"
|
| @@ -64,7 +64,6 @@ class ProcessInfo {
|
| DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
|
| };
|
|
|
| -
|
| // Singly-linked list of ProcessInfo objects for all active processes
|
| // started from Dart.
|
| class ProcessInfoList {
|
| @@ -76,7 +75,6 @@ class ProcessInfoList {
|
| active_processes_ = info;
|
| }
|
|
|
| -
|
| static intptr_t LookupProcessExitFd(pid_t pid) {
|
| MutexLocker locker(mutex_);
|
| ProcessInfo* current = active_processes_;
|
| @@ -89,7 +87,6 @@ class ProcessInfoList {
|
| return 0;
|
| }
|
|
|
| -
|
| static void RemoveProcess(pid_t pid) {
|
| MutexLocker locker(mutex_);
|
| ProcessInfo* prev = NULL;
|
| @@ -121,11 +118,9 @@ class ProcessInfoList {
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ProcessInfoList);
|
| };
|
|
|
| -
|
| ProcessInfo* ProcessInfoList::active_processes_ = NULL;
|
| Mutex* ProcessInfoList::mutex_ = new Mutex();
|
|
|
| -
|
| // The exit code handler sets up a separate thread which waits for child
|
| // processes to terminate. That separate thread can then get the exit code from
|
| // processes that have exited and communicate it to Dart through the
|
| @@ -239,13 +234,11 @@ class ExitCodeHandler {
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ExitCodeHandler);
|
| };
|
|
|
| -
|
| bool ExitCodeHandler::running_ = false;
|
| int ExitCodeHandler::process_count_ = 0;
|
| bool ExitCodeHandler::terminate_done_ = false;
|
| Monitor* ExitCodeHandler::monitor_ = new Monitor();
|
|
|
| -
|
| class ProcessStarter {
|
| public:
|
| ProcessStarter(const char* path,
|
| @@ -298,7 +291,6 @@ class ProcessStarter {
|
| }
|
| }
|
|
|
| -
|
| int Start() {
|
| // Create pipes required.
|
| int err = CreatePipes();
|
| @@ -431,7 +423,6 @@ class ProcessStarter {
|
| return 0;
|
| }
|
|
|
| -
|
| void NewProcess() {
|
| // Wait for parent process before setting up the child process.
|
| char msg;
|
| @@ -447,7 +438,6 @@ class ProcessStarter {
|
| }
|
| }
|
|
|
| -
|
| void ExecProcess() {
|
| if (TEMP_FAILURE_RETRY(dup2(write_out_[0], STDIN_FILENO)) == -1) {
|
| ReportChildError();
|
| @@ -481,7 +471,6 @@ class ProcessStarter {
|
| ReportChildError();
|
| }
|
|
|
| -
|
| void ExecDetachedProcess() {
|
| if (mode_ == kDetached) {
|
| ASSERT(write_out_[0] == -1);
|
| @@ -539,7 +528,6 @@ class ProcessStarter {
|
| }
|
| }
|
|
|
| -
|
| int RegisterProcess(pid_t pid) {
|
| int result;
|
| int event_fds[2];
|
| @@ -556,7 +544,6 @@ class ProcessStarter {
|
| return 0;
|
| }
|
|
|
| -
|
| int ReadExecResult() {
|
| int child_errno;
|
| int bytes_read = -1;
|
| @@ -574,7 +561,6 @@ class ProcessStarter {
|
| return 0;
|
| }
|
|
|
| -
|
| int ReadDetachedExecResult(pid_t* pid) {
|
| int child_errno;
|
| int bytes_read = -1;
|
| @@ -597,7 +583,6 @@ class ProcessStarter {
|
| return 0;
|
| }
|
|
|
| -
|
| void SetupDetached() {
|
| ASSERT(mode_ == kDetached);
|
|
|
| @@ -660,7 +645,6 @@ class ProcessStarter {
|
| VOID_TEMP_FAILURE_RETRY(close(read_err_[1]));
|
| }
|
|
|
| -
|
| int CleanupAndReturnError() {
|
| int actual_errno = errno;
|
| // If CleanupAndReturnError is called without an actual errno make
|
| @@ -673,7 +657,6 @@ class ProcessStarter {
|
| return actual_errno;
|
| }
|
|
|
| -
|
| void SetChildOsErrorMessage() {
|
| const int kBufferSize = 1024;
|
| char* error_message = DartUtils::ScopedCString(kBufferSize);
|
| @@ -681,7 +664,6 @@ class ProcessStarter {
|
| *os_error_message_ = error_message;
|
| }
|
|
|
| -
|
| void ReportChildError() {
|
| // In the case of failure in the child process write the errno and
|
| // the OS error message to the exec control pipe and exit.
|
| @@ -699,7 +681,6 @@ class ProcessStarter {
|
| exit(1);
|
| }
|
|
|
| -
|
| void ReportPid(int pid) {
|
| // In the case of starting a detached process the actual pid of that process
|
| // is communicated using the exec control pipe.
|
| @@ -709,7 +690,6 @@ class ProcessStarter {
|
| USE(bytes_written);
|
| }
|
|
|
| -
|
| void ReadChildError() {
|
| const int kMaxMessageSize = 256;
|
| char* message = DartUtils::ScopedCString(kMaxMessageSize);
|
| @@ -723,7 +703,6 @@ class ProcessStarter {
|
| }
|
| }
|
|
|
| -
|
| void ClosePipe(int* fds) {
|
| for (int i = 0; i < 2; i++) {
|
| if (fds[i] != -1) {
|
| @@ -733,7 +712,6 @@ class ProcessStarter {
|
| }
|
| }
|
|
|
| -
|
| void CloseAllPipes() {
|
| ClosePipe(exec_control_);
|
| ClosePipe(read_in_);
|
| @@ -741,7 +719,6 @@ class ProcessStarter {
|
| ClosePipe(write_out_);
|
| }
|
|
|
| -
|
| int read_in_[2]; // Pipe for stdout to child process.
|
| int read_err_[2]; // Pipe for stderr to child process.
|
| int write_out_[2]; // Pipe for stdin to child process.
|
| @@ -764,7 +741,6 @@ class ProcessStarter {
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ProcessStarter);
|
| };
|
|
|
| -
|
| int Process::Start(const char* path,
|
| char* arguments[],
|
| intptr_t arguments_length,
|
| @@ -784,7 +760,6 @@ int Process::Start(const char* path,
|
| return starter.Start();
|
| }
|
|
|
| -
|
| static bool CloseProcessBuffers(struct pollfd fds[3]) {
|
| int e = errno;
|
| VOID_TEMP_FAILURE_RETRY(close(fds[0].fd));
|
| @@ -794,7 +769,6 @@ static bool CloseProcessBuffers(struct pollfd fds[3]) {
|
| return false;
|
| }
|
|
|
| -
|
| bool Process::Wait(intptr_t pid,
|
| intptr_t in,
|
| intptr_t out,
|
| @@ -888,7 +862,6 @@ bool Process::Wait(intptr_t pid,
|
| return true;
|
| }
|
|
|
| -
|
| static int SignalMap(intptr_t id) {
|
| switch (static_cast<ProcessSignals>(id)) {
|
| case kSighup:
|
| @@ -953,22 +926,18 @@ static int SignalMap(intptr_t id) {
|
| return -1;
|
| }
|
|
|
| -
|
| bool Process::Kill(intptr_t id, int signal) {
|
| return (TEMP_FAILURE_RETRY(kill(id, SignalMap(signal))) != -1);
|
| }
|
|
|
| -
|
| void Process::TerminateExitCodeHandler() {
|
| ExitCodeHandler::TerminateExitCodeThread();
|
| }
|
|
|
| -
|
| intptr_t Process::CurrentProcessId() {
|
| return static_cast<intptr_t>(getpid());
|
| }
|
|
|
| -
|
| int64_t Process::CurrentRSS() {
|
| struct mach_task_basic_info info;
|
| mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
|
| @@ -981,7 +950,6 @@ int64_t Process::CurrentRSS() {
|
| return info.resident_size;
|
| }
|
|
|
| -
|
| int64_t Process::MaxRSS() {
|
| struct rusage usage;
|
| usage.ru_maxrss = 0;
|
| @@ -992,7 +960,6 @@ int64_t Process::MaxRSS() {
|
| return usage.ru_maxrss;
|
| }
|
|
|
| -
|
| static Mutex* signal_mutex = new Mutex();
|
| static SignalInfo* signal_handlers = NULL;
|
| static const int kSignalsCount = 7;
|
| @@ -1001,12 +968,10 @@ static const int kSignals[kSignalsCount] = {
|
| SIGQUIT // Allow VMService to listen on SIGQUIT.
|
| };
|
|
|
| -
|
| SignalInfo::~SignalInfo() {
|
| VOID_TEMP_FAILURE_RETRY(close(fd_));
|
| }
|
|
|
| -
|
| static void SignalHandler(int signal) {
|
| MutexLocker lock(signal_mutex);
|
| const SignalInfo* handler = signal_handlers;
|
| @@ -1019,7 +984,6 @@ static void SignalHandler(int signal) {
|
| }
|
| }
|
|
|
| -
|
| intptr_t Process::SetSignalHandler(intptr_t signal) {
|
| signal = SignalMap(signal);
|
| if (signal == -1) {
|
| @@ -1075,7 +1039,6 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
|
| return fds[0];
|
| }
|
|
|
| -
|
| void Process::ClearSignalHandler(intptr_t signal, Dart_Port port) {
|
| // Either the port is illegal or there is no current isolate, but not both.
|
| ASSERT((port != ILLEGAL_PORT) || (Dart_CurrentIsolate() == NULL));
|
|
|