fix reversion

It was not the wrong handle. The handle was not being closed, so bup
kept running.

Before 2670890b17, the code was:

withHandle StdinHandle createProcessSuccess cmd feeder

The stdin handle was not closed by the feeder.

Testing this:

	withHandle StdinHandle createProcessSuccess (proc "cat" []) (\h -> hPutStrLn h "hi")

There's a rather long pause, a couple seconds, before it completes, but
it does complete. With hClose h, it immediately completes. This must be
the GC noticing that h is out of scope and closing it.

It seems likely that the old code worked only by that accident.

So, other similar changes made in that and nearby commits may also
have this problem, and need to explicitly close handles that were
somehow implicitly closed before.
This commit is contained in:
Joey Hess 2020-06-05 17:10:52 -04:00
parent 291774779f
commit ef0024444b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -164,10 +164,12 @@ store r buprepo = byteStorer $ \k b p -> do
, std_err = UseHandle nullh
}
else cmd
feeder = \h -> meteredWrite p h b
feeder = \h -> do
meteredWrite p h b
hClose h
in withCreateProcess cmd' (go feeder cmd')
where
go feeder p _ (Just h) _ pid =
go feeder p (Just h) _ _ pid =
forceSuccessProcess p pid
`after`
feeder h