Index: runtime/bin/process_linux.cc |
diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc |
index 342d600e498a3ccebe6b8f3f21e3ead4e3c15527..1ab9a130ae7850c9ccd128355d48bb92ad183ade 100644 |
--- a/runtime/bin/process_linux.cc |
+++ b/runtime/bin/process_linux.cc |
@@ -9,15 +9,15 @@ |
#include "bin/process.h" |
-#include <errno.h> // NOLINT |
-#include <fcntl.h> // NOLINT |
-#include <poll.h> // NOLINT |
-#include <stdio.h> // NOLINT |
-#include <stdlib.h> // NOLINT |
-#include <string.h> // NOLINT |
+#include <errno.h> // NOLINT |
+#include <fcntl.h> // NOLINT |
+#include <poll.h> // NOLINT |
+#include <stdio.h> // NOLINT |
+#include <stdlib.h> // NOLINT |
+#include <string.h> // NOLINT |
#include <sys/resource.h> // NOLINT |
-#include <sys/wait.h> // NOLINT |
-#include <unistd.h> // NOLINT |
+#include <sys/wait.h> // NOLINT |
+#include <unistd.h> // NOLINT |
#include "bin/dartutils.h" |
#include "bin/fdutils.h" |
@@ -65,7 +65,6 @@ class ProcessInfo { |
DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |
}; |
- |
// Singly-linked list of ProcessInfo objects for all active processes |
// started from Dart. |
class ProcessInfoList { |
@@ -77,7 +76,6 @@ class ProcessInfoList { |
active_processes_ = info; |
} |
- |
static intptr_t LookupProcessExitFd(pid_t pid) { |
MutexLocker locker(mutex_); |
ProcessInfo* current = active_processes_; |
@@ -90,7 +88,6 @@ class ProcessInfoList { |
return 0; |
} |
- |
static void RemoveProcess(pid_t pid) { |
MutexLocker locker(mutex_); |
ProcessInfo* prev = NULL; |
@@ -122,11 +119,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 |
@@ -243,13 +238,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, |
@@ -302,7 +295,6 @@ class ProcessStarter { |
} |
} |
- |
int Start() { |
// Create pipes required. |
int err = CreatePipes(); |
@@ -427,7 +419,6 @@ class ProcessStarter { |
return 0; |
} |
- |
void NewProcess() { |
// Wait for parent process before setting up the child process. |
char msg; |
@@ -443,7 +434,6 @@ class ProcessStarter { |
} |
} |
- |
void ExecProcess() { |
if (TEMP_FAILURE_RETRY(dup2(write_out_[0], STDIN_FILENO)) == -1) { |
ReportChildError(); |
@@ -472,7 +462,6 @@ class ProcessStarter { |
ReportChildError(); |
} |
- |
void ExecDetachedProcess() { |
if (mode_ == kDetached) { |
ASSERT(write_out_[0] == -1); |
@@ -530,7 +519,6 @@ class ProcessStarter { |
} |
} |
- |
int RegisterProcess(pid_t pid) { |
int result; |
int event_fds[2]; |
@@ -545,7 +533,6 @@ class ProcessStarter { |
return 0; |
} |
- |
int ReadExecResult() { |
int child_errno; |
int bytes_read = -1; |
@@ -563,7 +550,6 @@ class ProcessStarter { |
return 0; |
} |
- |
int ReadDetachedExecResult(pid_t* pid) { |
int child_errno; |
int bytes_read = -1; |
@@ -586,7 +572,6 @@ class ProcessStarter { |
return 0; |
} |
- |
void SetupDetached() { |
ASSERT(mode_ == kDetached); |
@@ -649,7 +634,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 |
@@ -662,7 +646,6 @@ class ProcessStarter { |
return actual_errno; |
} |
- |
void SetChildOsErrorMessage() { |
const int kBufferSize = 1024; |
char* error_message = DartUtils::ScopedCString(kBufferSize); |
@@ -670,7 +653,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. |
@@ -691,7 +673,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. |
@@ -701,7 +682,6 @@ class ProcessStarter { |
USE(bytes_written); |
} |
- |
void ReadChildError() { |
const int kMaxMessageSize = 256; |
char* message = DartUtils::ScopedCString(kMaxMessageSize); |
@@ -715,7 +695,6 @@ class ProcessStarter { |
} |
} |
- |
void ClosePipe(int* fds) { |
for (int i = 0; i < 2; i++) { |
if (fds[i] != -1) { |
@@ -725,7 +704,6 @@ class ProcessStarter { |
} |
} |
- |
void CloseAllPipes() { |
ClosePipe(exec_control_); |
ClosePipe(read_in_); |
@@ -733,7 +711,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. |
@@ -756,7 +733,6 @@ class ProcessStarter { |
DISALLOW_IMPLICIT_CONSTRUCTORS(ProcessStarter); |
}; |
- |
int Process::Start(const char* path, |
char* arguments[], |
intptr_t arguments_length, |
@@ -776,7 +752,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)); |
@@ -786,7 +761,6 @@ static bool CloseProcessBuffers(struct pollfd fds[3]) { |
return false; |
} |
- |
bool Process::Wait(intptr_t pid, |
intptr_t in, |
intptr_t out, |
@@ -874,22 +848,18 @@ bool Process::Wait(intptr_t pid, |
return true; |
} |
- |
bool Process::Kill(intptr_t id, int signal) { |
return (TEMP_FAILURE_RETRY(kill(id, signal)) != -1); |
} |
- |
void Process::TerminateExitCodeHandler() { |
ExitCodeHandler::TerminateExitCodeThread(); |
} |
- |
intptr_t Process::CurrentProcessId() { |
return static_cast<intptr_t>(getpid()); |
} |
- |
int64_t Process::CurrentRSS() { |
// The second value in /proc/self/statm is the current RSS in pages. |
File* statm = File::Open("/proc/self/statm", File::kRead); |
@@ -912,7 +882,6 @@ int64_t Process::CurrentRSS() { |
return current_rss_pages * getpagesize(); |
} |
- |
int64_t Process::MaxRSS() { |
struct rusage usage; |
usage.ru_maxrss = 0; |
@@ -923,7 +892,6 @@ int64_t Process::MaxRSS() { |
return usage.ru_maxrss * KB; |
} |
- |
static Mutex* signal_mutex = new Mutex(); |
static SignalInfo* signal_handlers = NULL; |
static const int kSignalsCount = 7; |
@@ -932,12 +900,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; |
@@ -950,7 +916,6 @@ static void SignalHandler(int signal) { |
} |
} |
- |
intptr_t Process::SetSignalHandler(intptr_t signal) { |
bool found = false; |
for (int i = 0; i < kSignalsCount; i++) { |
@@ -998,7 +963,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)); |