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