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