restart coprocess in raw mode
Restarting a crashing git process could result in filename encoding issues when not in a unicode locale, as the restarted processes's handles were not read in raw mode. Since rawMode is always used when starting a coprocess, didn't bother to parameterise it and just always enable it for simplicity. This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
parent
f08ad2f916
commit
e23028d19b
7 changed files with 21 additions and 19 deletions
|
@ -13,7 +13,6 @@ module Utility.CoProcess (
|
|||
start,
|
||||
stop,
|
||||
query,
|
||||
rawMode
|
||||
) where
|
||||
|
||||
import Common
|
||||
|
@ -44,7 +43,15 @@ start numrestarts cmd params environ = do
|
|||
start' :: CoProcessSpec -> IO CoProcessState
|
||||
start' s = do
|
||||
(pid, from, to) <- startInteractiveProcess (coProcessCmd s) (coProcessParams s) (coProcessEnv s)
|
||||
rawMode from
|
||||
rawMode to
|
||||
return $ CoProcessState pid to from s
|
||||
where
|
||||
rawMode h = do
|
||||
fileEncoding h
|
||||
#ifdef mingw32_HOST_OS
|
||||
hSetNewlineMode h noNewlineTranslation
|
||||
#endif
|
||||
|
||||
stop :: CoProcessHandle -> IO ()
|
||||
stop ch = do
|
||||
|
@ -79,16 +86,3 @@ query ch send receive = do
|
|||
{ coProcessNumRestarts = coProcessNumRestarts (coProcessSpec s) - 1 }
|
||||
putMVar ch s'
|
||||
query ch send receive
|
||||
|
||||
rawMode :: CoProcessHandle -> IO CoProcessHandle
|
||||
rawMode ch = do
|
||||
s <- readMVar ch
|
||||
raw $ coProcessFrom s
|
||||
raw $ coProcessTo s
|
||||
return ch
|
||||
where
|
||||
raw h = do
|
||||
fileEncoding h
|
||||
#ifdef mingw32_HOST_OS
|
||||
hSetNewlineMode h noNewlineTranslation
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue