[project @ 2005-04-27 08:25:46 by simonmar]
authorsimonmar <unknown>
Wed, 27 Apr 2005 08:25:46 +0000 (08:25 +0000)
committersimonmar <unknown>
Wed, 27 Apr 2005 08:25:46 +0000 (08:25 +0000)
newTempName: instead of bumping the processId until we find a name
that isn't used, add an integer suffix to the processId.  This should
prevent temp-file conflicts that appear to have been affecting our
nightly builds and occasionally make -j.

The right way to allocate a temporary file is to create it straight
away, but I'm not sure of the implications of passing existing
temporary files to the various sub-processes that GHC executes, hence
this fix instead.

ghc/compiler/main/SysTools.lhs

index 1124728..6dadee4 100644 (file)
@@ -544,12 +544,12 @@ cleanTempFilesExcept dflags dont_delete
 newTempName :: DynFlags -> Suffix -> IO FilePath
 newTempName DynFlags{tmpDir=tmp_dir} extn
   = do x <- getProcessID
-       findTempName tmp_dir x
+       findTempName (tmp_dir ++ "/ghc" ++ show x ++ "_") 0
   where 
-    findTempName tmp_dir x
-      = do let filename = tmp_dir ++ "/ghc" ++ show x ++ '.':extn
+    findTempName prefix x
+      = do let filename = prefix ++ show x ++ '.':extn
           b  <- doesFileExist filename
-          if b then findTempName tmp_dir (x+1)
+          if b then findTempName prefix (x+1)
                else do consIORef v_FilesToClean filename -- clean it up later
                        return filename