Index: runtime/bin/process_win.cc |
diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc |
index 7903236a0164e4a98365ebf572d97aab1047298e..edc81fb01793e4d579717b94237b62e5ddf1d3f1 100644 |
--- a/runtime/bin/process_win.cc |
+++ b/runtime/bin/process_win.cc |
@@ -946,7 +946,9 @@ static Mutex* signal_mutex = new Mutex(); |
SignalInfo::~SignalInfo() { |
- reinterpret_cast<FileHandle*>(fd_)->Close(); |
+ FileHandle* file_handle = reinterpret_cast<FileHandle*>(fd_); |
+ file_handle->Close(); |
+ file_handle->Release(); |
} |
@@ -1005,7 +1007,12 @@ intptr_t Process::SetSignalHandler(intptr_t signal) { |
if (signal_handlers == NULL) { |
if (SetConsoleCtrlHandler(SignalHandler, true) == 0) { |
int error_code = GetLastError(); |
- delete write_handle; |
+ // Since SetConsoleCtrlHandler failed, the IO completion port will |
+ // never receive an event for this handle, and will therefore never |
+ // release the reference Retained by EnsureInitialized(). So, we |
+ // have to do a second Release() here. |
+ write_handle->Release(); |
+ write_handle->Release(); |
CloseProcessPipe(fds); |
SetLastError(error_code); |
return -1; |
@@ -1038,6 +1045,8 @@ void Process::ClearSignalHandler(intptr_t signal) { |
if (signal_handlers == NULL) { |
USE(SetConsoleCtrlHandler(SignalHandler, false)); |
} |
+ FileHandle* file_handle = reinterpret_cast<FileHandle*>(handler->fd()); |
+ file_handle->Release(); |
} |
delete handler; |
} |