2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: system.c,v 1.3 1998/12/02 13:27:59 simonm Exp $
6 * system Runtime Support
12 #ifdef HAVE_SYS_WAIT_H
28 #if defined(cygwin32_TARGET_OS)
29 /* The implementation of std. fork() has its problems
30 under cygwin32-b18, so we fall back on using libc's
31 system() instead. (It in turn has problems, as it
32 does not wait until the sub shell has finished before
33 returning. Using sleep() works around that.)
35 if (system(cmd) < 0) {
46 switch(pid = fork()) {
55 execl("/bin/sh", "sh", "-c", cmd, NULL);
59 while (waitpid(pid, &wstat, 0) < 0) {
68 return WEXITSTATUS(wstat);
69 else if (WIFSIGNALED(wstat)) {
70 ghc_errtype = ERR_INTERRUPTED;
71 ghc_errstr = "system command interrupted";
74 /* This should never happen */
75 ghc_errtype = ERR_OTHERERROR;
76 ghc_errstr = "internal error (process neither exited nor signalled)";