@@ -9,7 +9,7 @@ module Hakyll.Core.UnixFilter
99--------------------------------------------------------------------------------
1010import Control.Concurrent (forkIO)
1111import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
12−import Control.DeepSeq (NFData, deepseq)
12+import Control.DeepSeq (deepseq)
1313import Control.Monad (forM_)
1414import Data.ByteString.Lazy (ByteString)
1515import qualified Data.ByteString.Lazy as LB
@@ -57,7 +57,8 @@ unixFilter = unixFilterWith writer reader
5757 hPutStr handle input
5858 reader handle = do
5959 hSetEncoding handle localeEncoding
60− hGetContents handle
60+ out <- hGetContents handle
61+ deepseq out (return out)
6162
6263
6364--------------------------------------------------------------------------------
@@ -70,12 +71,14 @@ unixFilterLBS :: String -- ^ Program name
7071 -> [String] -- ^ Program args
7172 -> ByteString -- ^ Program input
7273 -> Compiler ByteString -- ^ Program output
73−unixFilterLBS = unixFilterWith LB.hPutStr LB.hGetContents
74+unixFilterLBS = unixFilterWith LB.hPutStr $ \handle -> do
75+ out <- LB.hGetContents handle
76+ LB.length out `seq` return out
7477
7578
7679--------------------------------------------------------------------------------
7780-- | Overloaded compiler
78−unixFilterWith :: (Monoid o, NFData o)
81+unixFilterWith :: Monoid o
7982 => (Handle -> i -> IO ()) -- ^ Writer
8083 -> (Handle -> IO o) -- ^ Reader
8184 -> String -- ^ Program name
@@ -96,7 +99,7 @@ unixFilterWith writer reader programName args input = do
9699
97100--------------------------------------------------------------------------------
98101-- | Internally used function
99−unixFilterIO :: (Monoid o, NFData o)
102+unixFilterIO :: Monoid o
100103 => (Handle -> i -> IO ())
101104 -> (Handle -> IO o)
102105 -> String
@@ -122,14 +125,14 @@ unixFilterIO writer reader programName args input = do
122125 -- Read from stdout
123126 _ <- forkIO $ do
124127 out <- reader outh
125− deepseq out (hClose outh)
128+ hClose outh
126129 writeIORef outRef out
127130 putMVar lock ()
128131
129132 -- Read from stderr
130133 _ <- forkIO $ do
131134 err <- hGetContents errh
132− deepseq err (hClose errh)
135+ hClose errh
133136 writeIORef errRef err
134137 putMVar lock ()
135138