diff options
Diffstat (limited to 'win32/system.c')
-rw-r--r-- | win32/system.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/win32/system.c b/win32/system.c new file mode 100644 index 000000000..02aaaa0a1 --- /dev/null +++ b/win32/system.c | |||
@@ -0,0 +1,22 @@ | |||
1 | #include "libbb.h" | ||
2 | |||
3 | int mingw_system(const char *cmd) | ||
4 | { | ||
5 | const char *argv[4] = { "sh", "-c", cmd, NULL }; | ||
6 | intptr_t proc; | ||
7 | HANDLE h; | ||
8 | DWORD ret = 0; | ||
9 | |||
10 | if (cmd == NULL) | ||
11 | return 1; | ||
12 | |||
13 | if ((proc=mingw_spawn_proc((char **)argv)) == -1) | ||
14 | return -1; | ||
15 | |||
16 | h = (HANDLE)proc; | ||
17 | WaitForSingleObject(h, INFINITE); | ||
18 | GetExitCodeProcess(h, &ret); | ||
19 | CloseHandle(h); | ||
20 | |||
21 | return ret << 8; | ||
22 | } | ||