[project @ 2000-12-11 14:42:21 by sewardj]
authorsewardj <unknown>
Mon, 11 Dec 2000 14:42:21 +0000 (14:42 +0000)
committersewardj <unknown>
Mon, 11 Dec 2000 14:42:21 +0000 (14:42 +0000)
Remove circular dependencies created by kludgedSystem.

ghc/compiler/main/DriverUtil.hs
ghc/compiler/main/TmpFiles.hs

index 4301d86..31808aa 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverUtil.hs,v 1.12 2000/12/11 12:30:58 rrt Exp $
+-- $Id: DriverUtil.hs,v 1.13 2000/12/11 14:42:21 sewardj Exp $
 --
 -- Utils for the driver
 --
@@ -13,7 +13,6 @@ module DriverUtil where
 #include "HsVersions.h"
 
 import Util
-import TmpFiles ( newTempName )
 
 import IOExts
 import Exception
@@ -185,6 +184,7 @@ newdir dir s = dir ++ '/':drop_longest_prefix s '/'
 remove_spaces :: String -> String
 remove_spaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
 
+
 -- system that works feasibly under Windows (i.e. passes the command line to sh,
 -- because system() under Windows doesn't look at SHELL, and always uses CMD.EXE)
 kludgedSystem cmd phase_name
@@ -193,12 +193,14 @@ kludgedSystem cmd phase_name
    exit_code <- system cmd `catchAllIO` 
                   (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
 #else
-   tmp <- newTempName "sh"
+   pid <- myGetProcessID
+   let tmp = "/tmp/sh" ++ show pid
    h <- openFile tmp WriteMode
    hPutStrLn h cmd
    hClose h
    exit_code <- system ("sh - " ++ tmp) `catchAllIO` 
-                  (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
+                  (\_ -> removeFile tmp >>
+                          throwDyn (PhaseFailed phase_name (ExitFailure 1)))
    removeFile tmp
 #endif
    return exit_code
index 872719e..823b79c 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: TmpFiles.hs,v 1.12 2000/12/11 12:30:58 rrt Exp $
+-- $Id: TmpFiles.hs,v 1.13 2000/12/11 14:42:21 sewardj Exp $
 --
 -- Temporary file management
 --
@@ -19,7 +19,6 @@ module TmpFiles (
 -- main
 import Config
 import Util
-import DriverUtil ( kludgedSystem )
 
 -- hslibs
 import Exception
@@ -81,4 +80,3 @@ add :: IORef [a] -> a -> IO ()
 add var x = do
   xs <- readIORef var
   writeIORef var (x:xs)
-