diff --git a/src/plugins/System/MkTemp.hs b/src/plugins/System/MkTemp.hs index 6613453..2055542 100644 --- a/src/plugins/System/MkTemp.hs +++ b/src/plugins/System/MkTemp.hs @@ -243,7 +243,9 @@ mkdir0700 dir = createDirectory dir -- #ifdef __MINGW32__ -- relies on Int == Int32 on Windows -foreign import ccall unsafe "_getpid" getProcessID :: IO Int +foreign import ccall unsafe "_getpid" getProcessID' :: IO Int +getProcessID :: IO Int +getProcessID = liftM abs getProcessID' #else getProcessID :: IO Int #ifdef CYGWIN diff --git a/src/plugins/System/Plugins/Env.hs b/src/plugins/System/Plugins/Env.hs index 14b0aae..ae73ad2 100644 --- a/src/plugins/System/Plugins/Env.hs +++ b/src/plugins/System/Plugins/Env.hs @@ -65,8 +65,7 @@ import System.IO.Unsafe ( unsafePerformIO ) import System.Directory ( doesFileExist ) #if defined(CYGWIN) || defined(__MINGW32__) import System.Environment ( getEnv ) - -import Control.Monad ( liftM ) +import System.IO.Error ( catch, ioError, isDoesNotExistError ) #endif import Control.Concurrent.MVar ( MVar(), newMVar, withMVar ) @@ -383,7 +382,9 @@ lookupPkg' p = withPkgEnvs env $ \fms -> go fms p #endif libs <- mapM (findHSlib libdirs) (hslibs ++ cbits) #if defined(CYGWIN) || defined(__MINGW32__) - syslibdir <- liftM ( \x -> x ++ "/SYSTEM") (getEnv "SYSTEMROOT") + sysroot <- catch (getEnv "SYSTEMROOT") + (\e -> if isDoesNotExistError e then return "C:/windows" else ioError e) -- guess at a reasonable default + let syslibdir = sysroot ++ "/SYSTEM" libs' <- mapM (findDLL $ syslibdir : libdirs) dlls #else libs' <- mapM (findDLL libdirs) dlls