From e4126500ef64c0b1ea61cc4b301795a3a084b94a Mon Sep 17 00:00:00 2001 From: icex2 Date: Sun, 20 Dec 2020 16:37:40 +0100 Subject: [PATCH] util/proc: Create util module for handling process related stuff --- src/main/util/Module.mk | 1 + src/main/util/proc.c | 15 +++++++++++++++ src/main/util/proc.h | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 src/main/util/proc.c create mode 100644 src/main/util/proc.h diff --git a/src/main/util/Module.mk b/src/main/util/Module.mk index 478e841..ab8d495 100644 --- a/src/main/util/Module.mk +++ b/src/main/util/Module.mk @@ -15,6 +15,7 @@ src_util := \ msg-thread.c \ net.c \ os.c \ + proc.c \ signal.c \ str.c \ thread.c \ diff --git a/src/main/util/proc.c b/src/main/util/proc.c new file mode 100644 index 0000000..eb2100e --- /dev/null +++ b/src/main/util/proc.c @@ -0,0 +1,15 @@ +#include + +#include + +void proc_terminate_current_process(uint32_t exit_code) +{ + HANDLE hnd; + + hnd = OpenProcess( + SYNCHRONIZE | PROCESS_TERMINATE, + TRUE, + GetCurrentProcessId()); + + TerminateProcess(hnd, 0); +} \ No newline at end of file diff --git a/src/main/util/proc.h b/src/main/util/proc.h new file mode 100644 index 0000000..3dc6906 --- /dev/null +++ b/src/main/util/proc.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +void proc_terminate_current_process(uint32_t exit_code); \ No newline at end of file