summaryrefslogtreecommitdiff
path: root/lang/ghc
diff options
context:
space:
mode:
Diffstat (limited to 'lang/ghc')
-rw-r--r--lang/ghc/Makefile2
-rw-r--r--lang/ghc/files/patch-libraries_base_GHC_Event_KQueue.hsc45
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