Skip to content

Commit

Permalink
Copy the execute_sync-function from krafix
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jun 17, 2024
1 parent ff35492 commit 738bd40
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Sources/kong.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,3 +587,23 @@ int main(int argc, char **argv) {

return 0;
}

#ifdef _WIN32
#include <Windows.h>
#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
}

0 comments on commit 738bd40

Please sign in to comment.