From 0372aa05acdf281e27402446e8cdb731a78a848e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 28 Oct 2015 13:11:29 -0400 Subject: propellor spin --- src/Utility/ConcurrentOutput.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Utility/ConcurrentOutput.hs') diff --git a/src/Utility/ConcurrentOutput.hs b/src/Utility/ConcurrentOutput.hs index a3cc54d2..71055f14 100644 --- a/src/Utility/ConcurrentOutput.hs +++ b/src/Utility/ConcurrentOutput.hs @@ -74,16 +74,27 @@ takeOutputLock' block = do lcker <- outputLockedBy <$> getOutputHandle v' <- tryTakeMVar lcker case v' of - Just orig@(ProcessLock h _) -> + Just orig@(ProcessLock h _) -> do + hPutStrLn stderr $ show ("CHECK STALE") + hFlush stderr -- if process has exited, lock is stale ifM (isJust <$> P.getProcessExitCode h) - ( havelock + ( do + hPutStrLn stderr $ show ("WAS STALE") + hFlush stderr + havelock , if block then do + hPutStrLn stderr $ show ("WAIT FOR PROCESS") + hFlush stderr void $ P.waitForProcess h havelock else do + hPutStrLn stderr $ show ("RESTORE") + hFlush stderr putMVar lcker orig + hPutStrLn stderr $ show ("RESTORE DONE") + hFlush stderr return False ) Just GeneralLock -> do -- cgit v1.3-2-g0d8e