2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: system.c,v 1.12 2001/05/18 16:54:06 simonmar Exp $
6 * system Runtime Support
9 /* The itimer stuff in this module is non-posix */
10 #define NON_POSIX_SOURCE
17 #if defined(mingw32_TARGET_OS)
18 /* There's no fork() under Windows, so we fall back on using libc's
19 system() instead. (It in turn has problems, as it does not wait
20 until the sub shell has finished before returning. Using Sleep()
21 works around that.) */
22 if (system(cmd) < 0) {
33 switch(pid = fork()) {
41 /* Reset the itimers in the child, so it doesn't get plagued
42 * by SIGVTALRM interrupts.
44 struct timeval tv_null = { 0, 0 };
46 itv.it_interval = tv_null;
47 itv.it_value = tv_null;
48 setitimer(ITIMER_REAL, &itv, NULL);
49 setitimer(ITIMER_VIRTUAL, &itv, NULL);
50 setitimer(ITIMER_PROF, &itv, NULL);
54 execl("/bin/sh", "sh", "-c", cmd, NULL);
59 while (waitpid(pid, &wstat, 0) < 0) {
66 return WEXITSTATUS(wstat);
67 else if (WIFSIGNALED(wstat)) {
71 /* This should never happen */