avoid blocked indefinitely on mvar on windows

by repeatedly reading lines and pausing since cannot do signal foo used on
unix
This commit is contained in:
Joey Hess 2013-12-04 17:24:37 -04:00
parent 4ebb35dc59
commit abb0b3103f

View file

@ -53,17 +53,20 @@ unboundDelay time = do
{- Pauses the main thread, letting children run until program termination. -}
waitForTermination :: IO ()
waitForTermination = do
#ifdef mingw32_HOST_OS
runEvery (Seconds 600) $
void getLine
#else
lock <- newEmptyMVar
#ifndef mingw32_HOST_OS
let check sig = void $
installHandler sig (CatchOnce $ putMVar lock ()) Nothing
check softwareTermination
#ifndef __ANDROID__
whenM (queryTerminal stdInput) $
check keyboardSignal
#endif
#endif
takeMVar lock
#endif
oneSecond :: Microseconds
oneSecond = 1000000