2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: system.c,v 1.5 1999/03/01 08:57:57 sof Exp $
6 * system Runtime Support
16 #ifndef mingw32_TARGET_OS
17 # ifdef HAVE_SYS_WAIT_H
18 # include <sys/wait.h>
34 #if defined(mingw32_TARGET_OS)
35 if (system(cmd) < 0) {
43 #if defined(cygwin32_TARGET_OS)
44 /* The implementation of std. fork() has its problems
45 under cygwin32-b18, so we fall back on using libc's
46 system() instead. (It in turn has problems, as it
47 does not wait until the sub shell has finished before
48 returning. Using sleep() works around that.)
50 if (system(cmd) < 0) {
61 switch(pid = fork()) {
70 execl("/bin/sh", "sh", "-c", cmd, NULL);
74 while (waitpid(pid, &wstat, 0) < 0) {
83 return WEXITSTATUS(wstat);
84 else if (WIFSIGNALED(wstat)) {
85 ghc_errtype = ERR_INTERRUPTED;
86 ghc_errstr = "system command interrupted";
89 /* This should never happen */
90 ghc_errtype = ERR_OTHERERROR;
91 ghc_errstr = "internal error (process neither exited nor signalled)";