Windows: Fix hang when adding several files at once.

This commit is contained in:
Joey Hess 2013-06-14 17:35:45 -04:00
parent e02fdd2270
commit 0e05613083
4 changed files with 35 additions and 17 deletions

View file

@ -43,7 +43,7 @@ start restartable cmd params env = do
start' :: CoProcessSpec -> IO CoProcessState start' :: CoProcessSpec -> IO CoProcessState
start' s = do start' s = do
(to, from, _err, pid) <- runInteractiveProcess (coProcessCmd s) (coProcessParams s) Nothing (coProcessEnv s) (pid, to, from) <- startInteractiveProcess (coProcessCmd s) (coProcessParams s) (coProcessEnv s)
return $ CoProcessState pid to from s return $ CoProcessState pid to from s
stop :: CoProcessHandle -> IO () stop :: CoProcessHandle -> IO ()

View file

@ -26,7 +26,7 @@ module Utility.Process (
withBothHandles, withBothHandles,
withQuietOutput, withQuietOutput,
createProcess, createProcess,
runInteractiveProcess, startInteractiveProcess,
stdinHandle, stdinHandle,
stdoutHandle, stdoutHandle,
stderrHandle, stderrHandle,
@ -34,7 +34,7 @@ module Utility.Process (
import qualified System.Process import qualified System.Process
import System.Process as X hiding (CreateProcess(..), createProcess, runInteractiveProcess, readProcess, readProcessWithExitCode, system, rawSystem, runInteractiveCommand, runProcess) import System.Process as X hiding (CreateProcess(..), createProcess, runInteractiveProcess, readProcess, readProcessWithExitCode, system, rawSystem, runInteractiveCommand, runProcess)
import System.Process hiding (createProcess, runInteractiveProcess, readProcess) import System.Process hiding (createProcess, readProcess)
import System.Exit import System.Exit
import System.IO import System.IO
import System.Log.Logger import System.Log.Logger
@ -300,17 +300,19 @@ createProcess p = do
debugProcess p debugProcess p
System.Process.createProcess p System.Process.createProcess p
runInteractiveProcess {- Starts an interactive process. Unlike runInteractiveProcess in
:: FilePath - System.Process, stderr is inherited. -}
-> [String] startInteractiveProcess
-> Maybe FilePath :: FilePath
-> Maybe [(String, String)] -> [String]
-> IO (Handle, Handle, Handle, ProcessHandle) -> Maybe [(String, String)]
runInteractiveProcess f args c e = do -> IO (ProcessHandle, Handle, Handle)
debugProcess $ (proc f args) startInteractiveProcess cmd args environ = do
{ std_in = CreatePipe let p = (proc cmd args)
, std_out = CreatePipe { std_in = CreatePipe
, std_err = CreatePipe , std_out = CreatePipe
, env = e , std_err = Inherit
} , env = environ
System.Process.runInteractiveProcess f args c e }
(Just from, Just to, _, pid) <- createProcess p
return (pid, to, from)

1
debian/changelog vendored
View file

@ -20,6 +20,7 @@ git-annex (4.20130602) UNRELEASED; urgency=low
with git annex sync or by the assistant. with git annex sync or by the assistant.
* Android: Fix use of cp command to not try to use features present * Android: Fix use of cp command to not try to use features present
only on build system. only on build system.
* Windows: Fix hang when adding several files at once.
-- Joey Hess <joeyh@debian.org> Mon, 10 Jun 2013 12:52:44 -0400 -- Joey Hess <joeyh@debian.org> Mon, 10 Jun 2013 12:52:44 -0400

View file

@ -180,3 +180,18 @@ info"]
# End of transcript or log. # End of transcript or log.
"""]] """]]
> Reproduced this, and git update-index was in fact not hanging.
> Instead, after that was done, it tried to stop the git hash-object
> process, and this hung.
>
> It seems that the use of runInteractiveProcess is at fault somehow,
> and I guess it must be due to it opening a pipe for stderr, which
> I don't need or want. Perhaps I need to ensure I read from that pipe,
> or windows keeps the process from terminating. (Unix would just toss the piped
> data away.)
>
> That was the only place runInteractiveProcess was used, so I replaced
> it with an alternative that lets stderr be inherited. With this change,
> I have successfully added 1000 files to the annex in one go, with no
> hang. Provisionally [[done]]. --[[Joey]]