2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: system.c,v 1.1 2001/06/28 14:15:04 simonmar Exp $
6 * system Runtime Support
9 /* The itimer stuff in this module is non-posix */
10 #define NON_POSIX_SOURCE
14 #if defined(mingw32_TARGET_OS)
21 #if defined(mingw32_TARGET_OS)
23 PROCESS_INFORMATION pInfo;
26 sInfo.cb = sizeof(STARTUPINFO);
27 sInfo.lpReserved = NULL;
28 sInfo.lpReserved2 = NULL;
29 sInfo.cbReserved2 = 0;
30 sInfo.lpDesktop = NULL;
34 if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo))
36 WaitForSingleObject(pInfo.hProcess, INFINITE);
37 if (GetExitCodeProcess(pInfo.hProcess, &retCode) == 0) return -1;
38 CloseHandle(pInfo.hProcess);
39 CloseHandle(pInfo.hThread);
45 switch(pid = fork()) {
53 /* Reset the itimers in the child, so it doesn't get plagued
54 * by SIGVTALRM interrupts.
56 struct timeval tv_null = { 0, 0 };
58 itv.it_interval = tv_null;
59 itv.it_value = tv_null;
60 setitimer(ITIMER_REAL, &itv, NULL);
61 setitimer(ITIMER_VIRTUAL, &itv, NULL);
62 setitimer(ITIMER_PROF, &itv, NULL);
66 execl("/bin/sh", "sh", "-c", cmd, NULL);
71 while (waitpid(pid, &wstat, 0) < 0) {
78 return WEXITSTATUS(wstat);
79 else if (WIFSIGNALED(wstat)) {
83 /* This should never happen */