[project @ 2002-02-14 07:32:17 by sof]
[ghc-base.git] / cbits / system.c
index 0873885..6c4e7f5 100644 (file)
@@ -1,18 +1,19 @@
 /* 
- * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
+ * (c) The University of Glasgow 2002
  *
- * $Id: system.c,v 1.2 2001/07/31 11:51:09 simonmar Exp $
+ * $Id: system.c,v 1.5 2002/02/07 11:13:30 simonmar Exp $
  *
  * system Runtime Support
  */
 
 /* The itimer stuff in this module is non-posix */
-#define NON_POSIX_SOURCE
+// #include "PosixSource.h"
 
-#include "HsCore.h"
+#include "HsBase.h"
 
 #if defined(mingw32_TARGET_OS)
 #include <windows.h>
+#include <stdlib.h>
 #endif
 
 HsInt
@@ -20,32 +21,7 @@ systemCmd(HsAddr cmd)
 {
   /* -------------------- WINDOWS VERSION --------------------- */
 #if defined(mingw32_TARGET_OS)
-  STARTUPINFO sInfo;
-  PROCESS_INFORMATION pInfo;
-  DWORD retCode;
-
-  sInfo.cb              = sizeof(STARTUPINFO);
-  sInfo.lpReserved      = NULL;
-  sInfo.lpReserved2     = NULL;
-  sInfo.cbReserved2     = 0;
-  sInfo.lpDesktop       = NULL;
-  sInfo.lpTitle         = NULL;
-  sInfo.dwFlags         = 0;
-
-  if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &sInfo, &pInfo))
-    /* The 'TRUE' says that the created process should share
-       handles with the current process.  This is vital to ensure
-       that error messages sent to stderr actually appear on the screen.
-       Since we are going to wait for the process to terminate anyway,
-       there is no problem with such sharing. */
-
-    return -1;
-  WaitForSingleObject(pInfo.hProcess, INFINITE);
-  if (GetExitCodeProcess(pInfo.hProcess, &retCode) == 0) return -1;
-  CloseHandle(pInfo.hProcess);
-  CloseHandle(pInfo.hThread);
-  return retCode;
-
+    return system(cmd);
 #else
   /* -------------------- UNIX VERSION --------------------- */
     int pid;