[Haskell-cafe] How to Hijack stdin,err,out, thread safely?

Hiromi ISHII konn.jinro at gmail.com
Tue Jun 30 18:56:00 UTC 2015


> On 2015/07/01 3:33,Jonas Scholl <anselm.scholl at tu-harburg.de> wrote:

> https://hackage.haskell.org/package/silently may be of interest to you.
> Although I do not now whether it is threadsafe.

Thanks! I didn't know about this package.
This package seems great, but after I did some experement, it turns out to be not thread-safe.
If we apply capture or silence to time-consuming actions, it eats entire output to stdout even
made by other thread. For example, following code does not output anything and captures the output by another thread:

main :: IO ()
main = do
  print =<< (replicateM_ 100 $ do
    threadDelay (10^5)
    putStrLn "Hey, I'm here!") `concurrently`
     (capture_ $ replicateM_ 100 $ do
        threadDelay (10^5)
        putStrLn "Hey, You're there!")

I'm now suspecting that implementing the thread-safe versions of silently / capture
is impossible...

-- Hiromi ISHII
konn.jinro at gmail.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150701/509bb80e/attachment.sig>

More information about the Haskell-Cafe mailing list