aboutsummaryrefslogtreecommitdiff
path: root/src/lib/process/process_win32.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-11-23 03:44:59 +0100
committerNick Mathewson <nickm@torproject.org>2018-12-17 16:39:28 -0500
commit4f611a1df70d2c5e4cb6261f75c1b82c9ed04598 (patch)
tree8f6c89be62eb526fa3459782c2f4a1e5b5ec42a2 /src/lib/process/process_win32.c
parent338137221c8bd89f6d611c0cd3bf7b8a85d02517 (diff)
downloadtor-4f611a1df70d2c5e4cb6261f75c1b82c9ed04598.tar.gz
tor-4f611a1df70d2c5e4cb6261f75c1b82c9ed04598.zip
Add process_terminate().
This patch adds support for process termination to the Process subsystem. See: https://bugs.torproject.org/28179
Diffstat (limited to 'src/lib/process/process_win32.c')
-rw-r--r--src/lib/process/process_win32.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/process/process_win32.c b/src/lib/process/process_win32.c
index 7422493deb..7b18903c70 100644
--- a/src/lib/process/process_win32.c
+++ b/src/lib/process/process_win32.c
@@ -271,6 +271,28 @@ process_win32_exec(process_t *process)
return PROCESS_STATUS_RUNNING;
}
+/** Terminate the given process. Returns true on success, otherwise false. */
+bool
+process_win32_terminate(process_t *process)
+{
+ tor_assert(process);
+
+ process_win32_t *win32_process = process_get_win32_process(process);
+
+ /* Terminate our process. */
+ BOOL ret;
+
+ ret = TerminateProcess(win32_process->process_information.hProcess, 0);
+
+ if (! ret) {
+ log_warn(LD_PROCESS, "TerminateProcess() failed: %s",
+ format_win32_error(GetLastError()));
+ return false;
+ }
+
+ return true;
+}
+
/** Returns the unique process identifier for the given <b>process</b>. */
process_pid_t
process_win32_get_pid(process_t *process)