mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 06:48:05 +01:00
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.
This commit is contained in:
parent
f8344c2d28
commit
34f8723dc7
1 changed files with 1 additions and 7 deletions
|
@ -3629,13 +3629,7 @@ tor_terminate_process(process_handle_t *process_handle)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (tor_get_exit_code(process_handle, 0, NULL) == PROCESS_EXIT_RUNNING) {
|
if (tor_get_exit_code(process_handle, 0, NULL) == PROCESS_EXIT_RUNNING) {
|
||||||
HANDLE handle;
|
HANDLE handle = process_handle->pid.hProcess;
|
||||||
/* 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;
|
|
||||||
|
|
||||||
if (!TerminateProcess(handle, 0))
|
if (!TerminateProcess(handle, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue