| Index: runtime/bin/process_win.cc
|
| diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc
|
| index bcf0c79dc80d8557b1ae59d48b8b4247967110aa..19378fa7e98a1538849a3abdc6cc735e97ea20d3 100644
|
| --- a/runtime/bin/process_win.cc
|
| +++ b/runtime/bin/process_win.cc
|
| @@ -9,8 +9,8 @@
|
|
|
| #include "bin/process.h"
|
|
|
| -#include <psapi.h> // NOLINT
|
| #include <process.h> // NOLINT
|
| +#include <psapi.h> // NOLINT
|
|
|
| #include "bin/builtin.h"
|
| #include "bin/dartutils.h"
|
| @@ -82,7 +82,6 @@ class ProcessInfo {
|
| DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
|
| };
|
|
|
| -
|
| // Singly-linked list of ProcessInfo objects for all active processes
|
| // started from Dart.
|
| class ProcessInfoList {
|
| @@ -201,15 +200,12 @@ class ProcessInfoList {
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ProcessInfoList);
|
| };
|
|
|
| -
|
| ProcessInfo* ProcessInfoList::active_processes_ = NULL;
|
| Mutex* ProcessInfoList::mutex_ = new Mutex();
|
|
|
| -
|
| // Types of pipes to create.
|
| enum NamedPipeType { kInheritRead, kInheritWrite, kInheritNone };
|
|
|
| -
|
| // Create a pipe for communicating with a new process. The handles array
|
| // will contain the read and write ends of the pipe. Based on the type
|
| // one of the handles will be inheritable.
|
| @@ -274,7 +270,6 @@ static bool CreateProcessPipe(HANDLE handles[2],
|
| return true;
|
| }
|
|
|
| -
|
| static void CloseProcessPipe(HANDLE handles[2]) {
|
| for (int i = kReadHandle; i < kWriteHandle; i++) {
|
| if (handles[i] != INVALID_HANDLE_VALUE) {
|
| @@ -286,7 +281,6 @@ static void CloseProcessPipe(HANDLE handles[2]) {
|
| }
|
| }
|
|
|
| -
|
| static void CloseProcessPipes(HANDLE handles1[2],
|
| HANDLE handles2[2],
|
| HANDLE handles3[2],
|
| @@ -297,7 +291,6 @@ static void CloseProcessPipes(HANDLE handles1[2],
|
| CloseProcessPipe(handles4);
|
| }
|
|
|
| -
|
| static int SetOsErrorMessage(char** os_error_message) {
|
| int error_code = GetLastError();
|
| const int kMaxMessageLength = 256;
|
| @@ -307,7 +300,6 @@ static int SetOsErrorMessage(char** os_error_message) {
|
| return error_code;
|
| }
|
|
|
| -
|
| // Open an inheritable handle to NUL.
|
| static HANDLE OpenNul() {
|
| SECURITY_ATTRIBUTES inherit_handle;
|
| @@ -322,7 +314,6 @@ static HANDLE OpenNul() {
|
| return nul;
|
| }
|
|
|
| -
|
| typedef BOOL(WINAPI* InitProcThreadAttrListFn)(LPPROC_THREAD_ATTRIBUTE_LIST,
|
| DWORD,
|
| DWORD,
|
| @@ -338,12 +329,10 @@ typedef BOOL(WINAPI* UpdateProcThreadAttrFn)(LPPROC_THREAD_ATTRIBUTE_LIST,
|
|
|
| typedef VOID(WINAPI* DeleteProcThreadAttrListFn)(LPPROC_THREAD_ATTRIBUTE_LIST);
|
|
|
| -
|
| static InitProcThreadAttrListFn init_proc_thread_attr_list = NULL;
|
| static UpdateProcThreadAttrFn update_proc_thread_attr = NULL;
|
| static DeleteProcThreadAttrListFn delete_proc_thread_attr_list = NULL;
|
|
|
| -
|
| static bool EnsureInitialized() {
|
| static bool load_attempted = false;
|
| static Mutex* mutex = new Mutex();
|
| @@ -365,7 +354,6 @@ static bool EnsureInitialized() {
|
| return (delete_proc_thread_attr_list != NULL);
|
| }
|
|
|
| -
|
| const int kMaxPipeNameSize = 80;
|
| template <int Count>
|
| static int GenerateNames(wchar_t pipe_names[Count][kMaxPipeNameSize]) {
|
| @@ -391,7 +379,6 @@ static int GenerateNames(wchar_t pipe_names[Count][kMaxPipeNameSize]) {
|
| return 0;
|
| }
|
|
|
| -
|
| class ProcessStarter {
|
| public:
|
| ProcessStarter(const char* path,
|
| @@ -502,14 +489,12 @@ class ProcessStarter {
|
| attribute_list_ = NULL;
|
| }
|
|
|
| -
|
| ~ProcessStarter() {
|
| if (attribute_list_ != NULL) {
|
| delete_proc_thread_attr_list(attribute_list_);
|
| }
|
| }
|
|
|
| -
|
| int Start() {
|
| // Create pipes required.
|
| int err = CreatePipes();
|
| @@ -607,7 +592,6 @@ class ProcessStarter {
|
| return 0;
|
| }
|
|
|
| -
|
| int CreatePipes() {
|
| // Generate unique pipe names for the four named pipes needed.
|
| wchar_t pipe_names[4][kMaxPipeNameSize];
|
| @@ -652,7 +636,6 @@ class ProcessStarter {
|
| return 0;
|
| }
|
|
|
| -
|
| int CleanupAndReturnError() {
|
| int error_code = SetOsErrorMessage(os_error_message_);
|
| CloseProcessPipes(stdin_handles_, stdout_handles_, stderr_handles_,
|
| @@ -660,7 +643,6 @@ class ProcessStarter {
|
| return error_code;
|
| }
|
|
|
| -
|
| HANDLE stdin_handles_[2];
|
| HANDLE stdout_handles_[2];
|
| HANDLE stderr_handles_[2];
|
| @@ -686,7 +668,6 @@ class ProcessStarter {
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(ProcessStarter);
|
| };
|
|
|
| -
|
| int Process::Start(const char* path,
|
| char* arguments[],
|
| intptr_t arguments_length,
|
| @@ -706,7 +687,6 @@ int Process::Start(const char* path,
|
| return starter.Start();
|
| }
|
|
|
| -
|
| class BufferList : public BufferListBase {
|
| public:
|
| BufferList() : read_pending_(true) {}
|
| @@ -754,7 +734,6 @@ class BufferList : public BufferListBase {
|
| DISALLOW_COPY_AND_ASSIGN(BufferList);
|
| };
|
|
|
| -
|
| class OverlappedHandle {
|
| public:
|
| OverlappedHandle() {}
|
| @@ -825,7 +804,6 @@ class OverlappedHandle {
|
| DISALLOW_COPY_AND_ASSIGN(OverlappedHandle);
|
| };
|
|
|
| -
|
| bool Process::Wait(intptr_t pid,
|
| intptr_t in,
|
| intptr_t out,
|
| @@ -909,7 +887,6 @@ bool Process::Wait(intptr_t pid,
|
| return true;
|
| }
|
|
|
| -
|
| bool Process::Kill(intptr_t id, int signal) {
|
| USE(signal); // signal is not used on Windows.
|
| HANDLE process_handle;
|
| @@ -931,17 +908,14 @@ bool Process::Kill(intptr_t id, int signal) {
|
| return result ? true : false;
|
| }
|
|
|
| -
|
| void Process::TerminateExitCodeHandler() {
|
| // Nothing needs to be done on Windows.
|
| }
|
|
|
| -
|
| intptr_t Process::CurrentProcessId() {
|
| return static_cast<intptr_t>(GetCurrentProcessId());
|
| }
|
|
|
| -
|
| int64_t Process::CurrentRSS() {
|
| PROCESS_MEMORY_COUNTERS pmc;
|
| if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
|
| @@ -950,7 +924,6 @@ int64_t Process::CurrentRSS() {
|
| return pmc.WorkingSetSize;
|
| }
|
|
|
| -
|
| int64_t Process::MaxRSS() {
|
| PROCESS_MEMORY_COUNTERS pmc;
|
| if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
|
| @@ -959,18 +932,15 @@ int64_t Process::MaxRSS() {
|
| return pmc.PeakWorkingSetSize;
|
| }
|
|
|
| -
|
| static SignalInfo* signal_handlers = NULL;
|
| static Mutex* signal_mutex = new Mutex();
|
|
|
| -
|
| SignalInfo::~SignalInfo() {
|
| FileHandle* file_handle = reinterpret_cast<FileHandle*>(fd_);
|
| file_handle->Close();
|
| file_handle->Release();
|
| }
|
|
|
| -
|
| BOOL WINAPI SignalHandler(DWORD signal) {
|
| MutexLocker lock(signal_mutex);
|
| const SignalInfo* handler = signal_handlers;
|
| @@ -986,7 +956,6 @@ BOOL WINAPI SignalHandler(DWORD signal) {
|
| return handled;
|
| }
|
|
|
| -
|
| intptr_t GetWinSignal(intptr_t signal) {
|
| switch (signal) {
|
| case kSighup:
|
| @@ -998,7 +967,6 @@ intptr_t GetWinSignal(intptr_t signal) {
|
| }
|
| }
|
|
|
| -
|
| intptr_t Process::SetSignalHandler(intptr_t signal) {
|
| signal = GetWinSignal(signal);
|
| if (signal == -1) {
|
| @@ -1042,7 +1010,6 @@ intptr_t Process::SetSignalHandler(intptr_t signal) {
|
| return reinterpret_cast<intptr_t>(new FileHandle(fds[kReadHandle]));
|
| }
|
|
|
| -
|
| void Process::ClearSignalHandler(intptr_t signal, Dart_Port port) {
|
| signal = GetWinSignal(signal);
|
| if (signal == -1) {
|
|
|