[project @ 1999-09-16 12:29:55 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / cbits / system.c
index d4670bf..2349ea7 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: system.c,v 1.3 1998/12/02 13:27:59 simonm Exp $
+ * $Id: system.c,v 1.5 1999/03/01 08:57:57 sof Exp $
  *
  * system Runtime Support
  */
@@ -9,8 +9,14 @@
 #include "Rts.h"
 #include "stgio.h"
 
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifndef mingw32_TARGET_OS
+# ifdef HAVE_SYS_WAIT_H
+#  include <sys/wait.h>
+# endif
 #endif
 
 #ifdef HAVE_VFORK_H
@@ -25,6 +31,15 @@ StgInt
 systemCmd(cmd)
 StgByteArray cmd;
 {
+#if defined(mingw32_TARGET_OS)
+  if (system(cmd) < 0) {
+     cvtErrno();
+     stdErrno();
+     return -1;
+  }
+  sleep(1);
+  return 0;
+#else
 #if defined(cygwin32_TARGET_OS)
    /* The implementation of std. fork() has its problems
       under cygwin32-b18, so we fall back on using libc's
@@ -77,4 +92,5 @@ StgByteArray cmd;
     }
     return -1;
 #endif
+#endif
 }