2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: system.c,v 1.4 1999/01/07 15:42:33 simonm Exp $
6 * system Runtime Support
16 #ifdef HAVE_SYS_WAIT_H
32 #if defined(cygwin32_TARGET_OS)
33 /* The implementation of std. fork() has its problems
34 under cygwin32-b18, so we fall back on using libc's
35 system() instead. (It in turn has problems, as it
36 does not wait until the sub shell has finished before
37 returning. Using sleep() works around that.)
39 if (system(cmd) < 0) {
50 switch(pid = fork()) {
59 execl("/bin/sh", "sh", "-c", cmd, NULL);
63 while (waitpid(pid, &wstat, 0) < 0) {
72 return WEXITSTATUS(wstat);
73 else if (WIFSIGNALED(wstat)) {
74 ghc_errtype = ERR_INTERRUPTED;
75 ghc_errstr = "system command interrupted";
78 /* This should never happen */
79 ghc_errtype = ERR_OTHERERROR;
80 ghc_errstr = "internal error (process neither exited nor signalled)";