aboutsummaryrefslogtreecommitdiff
path: root/win32/system.c
blob: 44a47f861496e730412796e437e53c6e10c0425a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "libbb.h"

int mingw_system(const char *cmd)
{
	const char *argv[4] = { "sh", "-c", cmd, NULL };
	intptr_t proc;
	HANDLE h;
	DWORD ret = 0;

	if (cmd == NULL)
		return 1;

	if ((proc=mingw_spawn_proc(argv)) == -1)
		return -1;

	h = (HANDLE)proc;
	WaitForSingleObject(h, INFINITE);
	GetExitCodeProcess(h, &ret);
	CloseHandle(h);

	return ret << 8;
}