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