hunk ./unix.cabal 2 -version: 2.4.0.0 +version: 2.4.0.1 hunk ./unix.cabal 50 - build-depends: base >= 4.1 && < 4.3 + build-depends: base >= 4.2 && < 4.3 hunk ./System/Posix/Temp.hsc 36 --- reading\/writing (only safe on GHC & Hugs) - -mkstemp :: String -> IO (String, Handle) +-- reading\/writing (only safe on GHC & Hugs). +-- The returned 'FilePath' is the (possibly relative) path of +-- the created file. +mkstemp :: String -> IO (FilePath, Handle) hunk ./System/Posix/Temp.hsc 38 --- the created file. +-- the created file, which is padded with 6 random characters. hunk ./System/Posix/Temp.hsc 48 - name <- mktemp template + name <- mktemp (template ++ "XXXXXX") hunk ./System/Posix/Temp.hsc 7 --- +-- hunk ./System/Posix/Temp.hsc 18 - mkstemp + mkstemp hunk ./System/Posix/Temp.hsc 21 - tmpfile: can we handle FILE*? - tmpnam: ISO C, should go in base? - tempname: dito + tmpfile: can we handle FILE*? + tmpnam: ISO C, should go in base? + tempname: dito hunk ./configure.ac 6 +AC_ARG_WITH([cc], + [C compiler], + [CC=$withval]) +AC_PROG_CC() + hunk ./System/Posix/Error.hs 19 + throwErrnoPathIfRetry, hunk ./System/Posix/Error.hs 21 + throwErrnoPathIfNullRetry, hunk ./System/Posix/Error.hs 23 - throwErrnoPathIfMinus1_ + throwErrnoPathIfMinus1_, + throwErrnoPathIfMinus1Retry hunk ./System/Posix/Error.hs 27 -import Foreign.C.Error +import Foreign +import Foreign.C + +throwErrnoPathIfMinus1Retry :: Num a => String -> FilePath -> IO a -> IO a +throwErrnoPathIfMinus1Retry loc path f = + throwErrnoPathIfRetry (== -1) loc path f + +throwErrnoPathIfNullRetry :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a) +throwErrnoPathIfNullRetry loc path f = + throwErrnoPathIfRetry (== nullPtr) loc path f + +throwErrnoPathIfRetry :: (a -> Bool) -> String -> FilePath -> IO a -> IO a +throwErrnoPathIfRetry pr loc path f = + do + res <- f + if pr res + then do + err <- getErrno + if err == eINTR + then throwErrnoPathIfRetry pr loc path f + else throwErrnoPath loc path + else return res hunk ./System/Posix/IO.hsc 182 - fd <- throwErrnoPathIfMinus1 "openFd" name (c_open s all_flags mode_w) + fd <- throwErrnoPathIfMinus1Retry "openFd" name (c_open s all_flags mode_w) hunk ./System/Posix/IO.hsc 241 -handleToFd h = withHandle "handleToFd" h $ \ h_@Handle__{haType=_,..} -> do +handleToFd h@(FileHandle _ m) = do + withHandle' "handleToFd" h m $ handleToFd' h +handleToFd h@(DuplexHandle _ r w) = do + withHandle' "handleToFd" h r $ handleToFd' h + withHandle' "handleToFd" h w $ handleToFd' h + -- for a DuplexHandle, make sure we mark both sides as closed, + -- otherwise a finalizer will come along later and close the other + -- side. (#3914) + +handleToFd' h h_@Handle__{haType=_,..} = do hunk ./System/Posix/IO.hsc 244 - withHandle' "handleToFd" h r $ handleToFd' h + _ <- withHandle' "handleToFd" h r $ handleToFd' h hunk ./System/Posix/IO.hsc 250 +handleToFd' :: Handle -> Handle__ -> IO (Handle__, Fd) addfile ./tests/3816.hs hunk ./tests/3816.hs 1 +import System.Posix +main = do + getAllGroupEntries >>= print . (>0) . length + getAllGroupEntries >>= print . (>0) . length addfile ./tests/3816.stdout hunk ./tests/3816.stdout 1 +True +True hunk ./tests/all.T 51 +test('3816', normal, compile_and_run, ['-package unix']) + hunk ./System/Posix/User.hsc 225 - withMVar lock $ \_ -> worker [] + withMVar lock $ \_ -> bracket_ c_setgrent c_endgrent $ worker [] hunk ./System/Posix/User.hsc 237 +foreign import ccall unsafe "setgrent" + c_setgrent :: IO () +foreign import ccall unsafe "endgrent" + c_endgrent :: IO () hunk ./System/Posix/Process.hsc 247 -in the parent. Another example is the I\/O manager thread: since the -I\/O manager isn't running in the child, attempting to do any -Handle-based I\/O will deadlock. +in the parent. hunk ./System/Posix/Process.hsc 249 -Using 'forkProcess' in order to do 'executeFile' is likely to work. -Anything else: you're on your own. +GHC note: 'forkProcess' is not currently supported when using multiple +processors (@+RTS -N@), although it is supported with @-threaded@ as +long as only one processor is being used. addfile ./tests/queryfdoption01.stdin hunk ./tests/queryfdoption01.stdin 1 +You can't fcntl(fd, F_SETFL, O_NONBLOCK) /dev/null on (Open)BSD, +so just supply this dummy file instead of running this test on +/dev/null. hunk ./tests/all.T 51 +# This test fails for me on x86/Linux with a "does not exist" error. +# Running with strace shows it is trying to talk to winbindd (part of +# Samba), so I think the failure has nothing to do with GHC. Also it +# works on a different machine that doesn't have Samba installed. +# --SDM 18/05/2010 hunk ./unix.cabal 50 - build-depends: base >= 4.2 && < 4.3 + build-depends: base >= 4.2 && < 4.4 hunk ./System/Posix/User.hsc 42 + setEffectiveUserID, + setEffectiveGroupID, + setGroups hunk ./System/Posix/User.hsc 115 +-- | @setGroups@ calls @setgroups@ to set the list of +-- supplementary @GroupID@s associated with the current process. +setGroups :: [GroupID] -> IO () +setGroups groups = do + withArrayLen groups $ \ ngroups arr -> + throwErrnoIfMinus1_ "setGroups" (c_setgroups (fromIntegral ngroups) arr) + +foreign import ccall unsafe "setgroups" + c_setgroups :: CInt -> Ptr CGid -> IO CInt + hunk ./System/Posix/User.hsc 146 +-- | @setEffectiveUserID uid@ calls @seteuid@ to set the effective +-- user-id associated with the current process to @uid@. This +-- does not update the real user-id or set-user-id. +setEffectiveUserID :: UserID -> IO () +setEffectiveUserID uid = throwErrnoIfMinus1_ "setEffectiveUserID" (c_seteuid uid) + +foreign import ccall unsafe "seteuid" + c_seteuid :: CUid -> IO CInt + hunk ./System/Posix/User.hsc 163 +-- | @setEffectiveGroupID uid@ calls @setegid@ to set the effective +-- group-id associated with the current process to @gid@. This +-- does not update the real group-id or set-group-id. +setEffectiveGroupID :: GroupID -> IO () +setEffectiveGroupID gid = + throwErrnoIfMinus1_ "setEffectiveGroupID" (c_setegid gid) + + +foreign import ccall unsafe "setegid" + c_setegid :: CGid -> IO CInt +