]> dgit.raspbian.org Git - git-annex.git/commitdiff
finish conversion to hGetLineUntilExitOrEOF
authorJoey Hess <joeyh@joeyh.name>
Wed, 18 Nov 2020 18:54:02 +0000 (14:54 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 18 Nov 2020 18:54:02 +0000 (14:54 -0400)
started in aafae46bcbb2a9533364b65be5fc05b379898aa1

Utility/Metered.hs
Utility/Process.hs

index d39e39bfafc254a05bc0cc631260d08f33ab2564..888e7e14162f229102e904f1cc4a4d97efb78b5d 100644 (file)
@@ -290,12 +290,11 @@ commandMeterExitCode' progressparser oh mmeter meterupdate cmd params mkprocess
                                                        meterupdate bytes
                                                feedprogress sendtotalsize' bytes buf' h
 
-       handlestderr ph h = unlessM (hIsEOF h) $ do
-               cancelOnExit ph (hGetLine h) >>= \case
-                       Just l -> do
-                               stderrHandler oh l
-                               handlestderr ph h
-                       Nothing -> return ()
+       handlestderr ph h = hGetLineUntilExitOrEOF ph h >>= \case
+               Just l -> do
+                       stderrHandler oh l
+                       handlestderr ph h
+               Nothing -> return ()
 
 {- Runs a command, that may display one or more progress meters on
  - either stdout or stderr, and prevents the meters from being displayed.
@@ -323,13 +322,12 @@ demeterCommandEnv oh cmd params environ = do
  - beginning of the line when updating a progress display).
  -}
 avoidProgress :: Bool -> ProcessHandle -> Handle -> (String -> IO ()) -> IO ()
-avoidProgress doavoid ph h emitter = unlessM (hIsEOF h) $
-       cancelOnExit ph (hGetLine h) >>= \case
-               Just s -> do
-                       unless (doavoid && '\r' `elem` s) $
-                               emitter s
-                       avoidProgress doavoid ph h emitter
-               Nothing -> return ()
+avoidProgress doavoid ph h emitter = hGetLineUntilExitOrEOF ph h >>= \case
+       Just s -> do
+               unless (doavoid && '\r' `elem` s) $
+                       emitter s
+               avoidProgress doavoid ph h emitter
+       Nothing -> return ()
 
 outputFilter
        :: FilePath
index 755226471067757cc4ecc58566dc15fedc9ec3a4..1348e9ee92a387aa5d4603e487af81279a3e8743 100644 (file)
@@ -231,9 +231,9 @@ cleanupProcess (mb_stdin, mb_stdout, mb_stderr, pid) = do
        void $ waitForProcess pid
 #endif
 
-{- | Like hGetLine, reads a line from the Handle. If the Handle is already
- - closed, returns Nothing. If the process exits without writing a line,
- - also returns Nothing.
+{- | Like hGetLine, reads a line from the Handle. Returns Nothing if end of
+ - file is reached, or if the process has exited and there is nothing more
+ - buffered to read from the handle.
  -
  - This is useful to protect against situations where the process might
  - have transferred the handle being read to another process, and so