diff options
author | Gleb Popov <arrowd@FreeBSD.org> | 2024-09-23 11:27:34 +0300 |
---|---|---|
committer | Gleb Popov <arrowd@FreeBSD.org> | 2024-09-23 11:28:44 +0300 |
commit | 838c356b1752e1cb73bb21bfa7710e1dcbc22b2b (patch) | |
tree | 0b480bc07c5e1f4a5d0b2146fe1e8ddff9bbdeb6 /lang/ghc | |
parent | games/exult-devel: Update to 20240923 snapshot (diff) |
lang/ghc: Pull a patch from upstream fixing a forking bug
Diffstat (limited to 'lang/ghc')
-rw-r--r-- | lang/ghc/Makefile | 2 | ||||
-rw-r--r-- | lang/ghc/files/patch-libraries_base_GHC_Event_KQueue.hsc | 45 |
2 files changed, 46 insertions, 1 deletions
diff --git a/lang/ghc/Makefile b/lang/ghc/Makefile index ff93d9d2b7a7..a61a0477f0e3 100644 --- a/lang/ghc/Makefile +++ b/lang/ghc/Makefile @@ -1,6 +1,6 @@ PORTNAME= ghc PORTVERSION= ${GHC_VERSION} -PORTREVISION?= 0 +PORTREVISION?= 1 CATEGORIES= lang haskell MASTER_SITES= https://www.haskell.org/ghc/dist/${PORTVERSION}/:source \ LOCAL/arrowd/:boot diff --git a/lang/ghc/files/patch-libraries_base_GHC_Event_KQueue.hsc b/lang/ghc/files/patch-libraries_base_GHC_Event_KQueue.hsc new file mode 100644 index 000000000000..1413a39d9705 --- /dev/null +++ b/lang/ghc/files/patch-libraries_base_GHC_Event_KQueue.hsc @@ -0,0 +1,45 @@ +https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13276 + +--- libraries/base/GHC/Event/KQueue.hsc.orig 2024-06-30 22:49:26 UTC ++++ libraries/base/GHC/Event/KQueue.hsc +@@ -44,8 +44,8 @@ import GHC.Event.Internal (Timeout(..)) + import GHC.Real (quotRem, fromIntegral) + import GHC.Show (Show(show)) + import GHC.Event.Internal (Timeout(..)) +-import System.Posix.Internals (c_close) +-import System.Posix.Types (Fd(..)) ++import System.Posix.Internals (c_close, c_getpid) ++import System.Posix.Types (Fd(..), CPid) + import qualified GHC.Event.Array as A + + #if defined(netbsd_HOST_OS) +@@ -73,19 +73,26 @@ data KQueue = KQueue { + data KQueue = KQueue { + kqueueFd :: {-# UNPACK #-} !KQueueFd + , kqueueEvents :: {-# UNPACK #-} !(A.Array Event) ++ , kqueuePid :: {-# UNPACK #-} !CPid -- ^ pid, used to detect forks + } + + new :: IO E.Backend + new = do + kqfd <- kqueue + events <- A.new 64 +- let !be = E.backend poll modifyFd modifyFdOnce delete (KQueue kqfd events) ++ pid <- c_getpid ++ let !be = E.backend poll modifyFd modifyFdOnce delete (KQueue kqfd events pid) + return be + + delete :: KQueue -> IO () + delete kq = do +- _ <- c_close . fromKQueueFd . kqueueFd $ kq +- return () ++ -- detect forks: the queue isn't inherited by a child process created with ++ -- fork. Hence we mustn't try to close the old fd or we might close a random ++ -- one (e.g. the one used by timerfd, cf #24672). ++ pid <- c_getpid ++ when (pid == kqueuePid kq) $ do ++ _ <- c_close . fromKQueueFd . kqueueFd $ kq ++ return () + + modifyFd :: KQueue -> Fd -> E.Event -> E.Event -> IO Bool + modifyFd kq fd oevt nevt = do |