[darcs-users] Bug in Windows MSYS in Darcs 2.0.2

Salvatore Insalaco kirby81 at gmail.com
Tue Jul 8 08:33:58 UTC 2008


Darcs 2.0.2 introduced a Windows issue (not present in 2.0.1rc2) that
makes darcs crash every time it prompts for something to the user.

The issue is that darcs is compiled with "-threaded" by default, and
in Utils.lhs there's:
askUser :: String -> IO String
askUser prompt = withThread $ withoutProgress $ do putStr prompt
                                                   hFlush stdout
                                                   threadWaitRead 0
#ifndef WIN32
                                                   getLine
#else
                                                   stripCr `fmap` getLine
#endif

Unfortunately threadWaitRead just crashes on windows msys when
threaded RTS is used
(http://hackage.haskell.org/trac/ghc/ticket/2408).

The solution is pretty easy:
askUser :: String -> IO String
askUser prompt = withThread $ withoutProgress $ do putStr prompt
                                                   hFlush stdout
#ifndef WIN32
                                                   threadWaitRead 0
                                                   getLine
#else
                                                   stripCr `fmap` getLine
#endif

It would be even better to check just for msys, not WIN32 (I don't
remember the define name at the moment).

With this change I guess that windows users lose a bit of ctrl-c-ness,
but at least it doesn't crash :).

Salvatore


More information about the darcs-users mailing list