From 738bd4094e6b9a78af5a52679ef53f90e2c0ab59 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Mon, 17 Jun 2024 18:48:30 +0200 Subject: [PATCH] Copy the execute_sync-function from krafix --- Sources/kong.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sources/kong.c b/Sources/kong.c index 12f748d..49fe681 100644 --- a/Sources/kong.c +++ b/Sources/kong.c @@ -587,3 +587,23 @@ int main(int argc, char **argv) { return 0; } + +#ifdef _WIN32 +#include +#endif + +void execute_sync(const char* command) { +#ifdef _WIN32 + STARTUPINFOA startupInfo; + PROCESS_INFORMATION processInfo; + memset(&startupInfo, 0, sizeof(startupInfo)); + memset(&processInfo, 0, sizeof(processInfo)); + startupInfo.cb = sizeof(startupInfo); + CreateProcessA(nullptr, (char*)command, nullptr, nullptr, FALSE, CREATE_DEFAULT_ERROR_MODE, "PATH=%PATH%;.\\cygwin\\bin\0", nullptr, &startupInfo, &processInfo); + WaitForSingleObject(processInfo.hProcess, INFINITE); + CloseHandle(processInfo.hProcess); + CloseHandle(processInfo.hThread); +#else + system(command); +#endif +}