fix a annex.pidlock issue

That made eg git-annex get of an unlocked file hang until the
annex.pidlocktimeout and then fail.

This fix should be fully thread safe no matter what else git-annex is
doing.

Only using runsGitAnnexChildProcess in the one place it's known to be a
problem. Could audit for all places where git-annex runs itself as a child
and add it to all of them, later.
This commit is contained in:
Joey Hess 2020-06-17 15:13:52 -04:00
parent 9583b267f5
commit 82448bdf39
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
10 changed files with 247 additions and 43 deletions

View file

@ -10,6 +10,7 @@
module Utility.Env.Set (
setEnv,
unsetEnv,
legalInEnvVar,
) where
#ifdef mingw32_HOST_OS
@ -18,6 +19,7 @@ import Utility.Env
#else
import qualified System.Posix.Env as PE
#endif
import Data.Char
{- Sets an environment variable. To overwrite an existing variable,
- overwrite must be True.
@ -41,3 +43,7 @@ unsetEnv = PE.unsetEnv
#else
unsetEnv = System.SetEnv.unsetEnv
#endif
legalInEnvVar :: Char -> Bool
legalInEnvVar '_' = True
legalInEnvVar c = isAsciiLower c || isAsciiUpper c || (isNumber c && isAscii c)