aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-10 11:16:42 -0400
committerNick Mathewson <nickm@torproject.org>2014-06-14 11:40:27 -0400
commit34f8723dc784142b30d92bbbdeb37089ae7a3bc5 (patch)
treed3b61e791a0a130cf5cfc7a9d91d1d7d5ac6a2ce
parentf8344c2d28be2489c8abadd694b5b96fe18efc02 (diff)
downloadtor-34f8723dc784142b30d92bbbdeb37089ae7a3bc5.tar
tor-34f8723dc784142b30d92bbbdeb37089ae7a3bc5.tar.gz
On Windows, terminate processes by handle, not pid
When we create a process yourself with CreateProcess, we get a handle to the process in the PROCESS_INFO output structure. But instead of using that handle, we were manually looking up a _new_ handle based on the process ID, which is a poor idea, since the process ID might refer to a new process later on, but the handle can't.
-rw-r--r--src/common/util.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 0a1410139..f79e72bea 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3629,13 +3629,7 @@ tor_terminate_process(process_handle_t *process_handle)
{
#ifdef _WIN32
if (tor_get_exit_code(process_handle, 0, NULL) == PROCESS_EXIT_RUNNING) {
- HANDLE handle;
- /* If the signal is outside of what GenerateConsoleCtrlEvent can use,
- attempt to open and terminate the process. */
- handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE,
- process_handle->pid.dwProcessId);
- if (!handle)
- return -1;
+ HANDLE handle = process_handle->pid.hProcess;
if (!TerminateProcess(handle, 0))
return -1;