Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
| 6 | 6 |
| 7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
| 8 #if defined(HOST_OS_WINDOWS) | 8 #if defined(HOST_OS_WINDOWS) |
| 9 | 9 |
| 10 #include "bin/process.h" | 10 #include "bin/process.h" |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 intptr_t Process::CurrentProcessId() { | 939 intptr_t Process::CurrentProcessId() { |
| 940 return static_cast<intptr_t>(GetCurrentProcessId()); | 940 return static_cast<intptr_t>(GetCurrentProcessId()); |
| 941 } | 941 } |
| 942 | 942 |
| 943 | 943 |
| 944 static SignalInfo* signal_handlers = NULL; | 944 static SignalInfo* signal_handlers = NULL; |
| 945 static Mutex* signal_mutex = new Mutex(); | 945 static Mutex* signal_mutex = new Mutex(); |
| 946 | 946 |
| 947 | 947 |
| 948 SignalInfo::~SignalInfo() { | 948 SignalInfo::~SignalInfo() { |
| 949 reinterpret_cast<FileHandle*>(fd_)->Close(); | 949 FileHandle* file_handle = reinterpret_cast<FileHandle*>(fd_); |
| 950 file_handle->Close(); | |
| 951 file_handle->Release(); | |
| 950 } | 952 } |
| 951 | 953 |
| 952 | 954 |
| 953 BOOL WINAPI SignalHandler(DWORD signal) { | 955 BOOL WINAPI SignalHandler(DWORD signal) { |
| 954 MutexLocker lock(signal_mutex); | 956 MutexLocker lock(signal_mutex); |
| 955 const SignalInfo* handler = signal_handlers; | 957 const SignalInfo* handler = signal_handlers; |
| 956 bool handled = false; | 958 bool handled = false; |
| 957 while (handler != NULL) { | 959 while (handler != NULL) { |
| 958 if (handler->signal() == signal) { | 960 if (handler->signal() == signal) { |
| 959 int value = 0; | 961 int value = 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 SetLastError(error_code); | 1000 SetLastError(error_code); |
| 999 return -1; | 1001 return -1; |
| 1000 } | 1002 } |
| 1001 MutexLocker lock(signal_mutex); | 1003 MutexLocker lock(signal_mutex); |
| 1002 FileHandle* write_handle = new FileHandle(fds[kWriteHandle]); | 1004 FileHandle* write_handle = new FileHandle(fds[kWriteHandle]); |
| 1003 write_handle->EnsureInitialized(EventHandler::delegate()); | 1005 write_handle->EnsureInitialized(EventHandler::delegate()); |
| 1004 intptr_t write_fd = reinterpret_cast<intptr_t>(write_handle); | 1006 intptr_t write_fd = reinterpret_cast<intptr_t>(write_handle); |
| 1005 if (signal_handlers == NULL) { | 1007 if (signal_handlers == NULL) { |
| 1006 if (SetConsoleCtrlHandler(SignalHandler, true) == 0) { | 1008 if (SetConsoleCtrlHandler(SignalHandler, true) == 0) { |
| 1007 int error_code = GetLastError(); | 1009 int error_code = GetLastError(); |
| 1008 delete write_handle; | 1010 write_handle->Release(); |
|
zra
2017/03/25 22:39:50
// Since SetConsoleCtrlHandler failed, the IO comp
| |
| 1009 CloseProcessPipe(fds); | 1011 CloseProcessPipe(fds); |
| 1010 SetLastError(error_code); | 1012 SetLastError(error_code); |
| 1011 return -1; | 1013 return -1; |
| 1012 } | 1014 } |
| 1013 } | 1015 } |
| 1014 signal_handlers = new SignalInfo(write_fd, signal, signal_handlers); | 1016 signal_handlers = new SignalInfo(write_fd, signal, signal_handlers); |
| 1015 return reinterpret_cast<intptr_t>(new FileHandle(fds[kReadHandle])); | 1017 return reinterpret_cast<intptr_t>(new FileHandle(fds[kReadHandle])); |
| 1016 } | 1018 } |
| 1017 | 1019 |
| 1018 | 1020 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1031 } | 1033 } |
| 1032 handler = handler->next(); | 1034 handler = handler->next(); |
| 1033 } | 1035 } |
| 1034 if (handler != NULL) { | 1036 if (handler != NULL) { |
| 1035 if (signal_handlers == handler) { | 1037 if (signal_handlers == handler) { |
| 1036 signal_handlers = handler->next(); | 1038 signal_handlers = handler->next(); |
| 1037 } | 1039 } |
| 1038 if (signal_handlers == NULL) { | 1040 if (signal_handlers == NULL) { |
| 1039 USE(SetConsoleCtrlHandler(SignalHandler, false)); | 1041 USE(SetConsoleCtrlHandler(SignalHandler, false)); |
| 1040 } | 1042 } |
| 1043 FileHandle* file_handle = reinterpret_cast<FileHandle*>(handler->fd()); | |
| 1044 file_handle->Release(); | |
| 1041 } | 1045 } |
| 1042 delete handler; | 1046 delete handler; |
| 1043 } | 1047 } |
| 1044 | 1048 |
| 1045 } // namespace bin | 1049 } // namespace bin |
| 1046 } // namespace dart | 1050 } // namespace dart |
| 1047 | 1051 |
| 1048 #endif // defined(HOST_OS_WINDOWS) | 1052 #endif // defined(HOST_OS_WINDOWS) |
| 1049 | 1053 |
| 1050 #endif // !defined(DART_IO_DISABLED) | 1054 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |