-system cmd =
- withCString cmd $ \s -> do
- status <- throwErrnoIfMinus1 "system" (primSystem s)
- case status of
- 0 -> return ExitSuccess
- n -> return (ExitFailure n)
-
-foreign import ccall unsafe "systemCmd" primSystem :: CString -> IO Int
-
-{- |
-The same as 'system', but bypasses the shell (GHC only).
-Will behave more portably between systems,
-because there is no interpretation of shell metasyntax.
--}
-
-rawSystem :: FilePath -> [String] -> IO ExitCode
-
-#ifndef mingw32_TARGET_OS
+system str = do
+#if mingw32_HOST_OS
+ p <- runCommand str
+ waitForProcess p
+#else
+ -- The POSIX version of system needs to do some manipulation of signal
+ -- handlers. Since we're going to be synchronously waiting for the child,
+ -- we want to ignore ^C in the parent, but handle it the default way
+ -- in the child (using SIG_DFL isn't really correct, it should be the
+ -- original signal handler, but the GHC RTS will have already set up
+ -- its own handler and we don't want to use that).
+ old_int <- installHandler sigINT Ignore Nothing
+ old_quit <- installHandler sigQUIT Ignore Nothing
+ (cmd,args) <- commandToProcess str
+ p <- runProcessPosix "runCommand" cmd args Nothing Nothing
+ Nothing Nothing Nothing
+ (Just defaultSignal) (Just defaultSignal)
+ r <- waitForProcess p
+ installHandler sigINT old_int Nothing
+ installHandler sigQUIT old_quit Nothing
+ return r
+#endif /* mingw32_HOST_OS */
+#endif /* __GLASGOW_HASKELL__ */