look for sysctl in some common sbin locations when it's not in PATH

This commit is contained in:
Joey Hess 2012-10-06 16:16:31 -04:00
parent d7289a13e5
commit 6cad247c5f
2 changed files with 12 additions and 5 deletions

View file

@ -164,10 +164,11 @@ tooManyWatches hook dir = do
]
querySysctl :: Read a => [CommandParam] -> IO (Maybe a)
querySysctl ps = do
v <- catchMaybeIO $ readProcess "sysctl" (toCommand ps)
case v of
Nothing -> return Nothing
Just s -> return $ parsesysctl s
querySysctl ps = getM go ["sysctl", "/sbin/sysctl", "/usr/sbin/sysctl"]
where
go p = do
v <- catchMaybeIO $ readProcess p (toCommand ps)
case v of
Nothing -> return Nothing
Just s -> return $ parsesysctl s
parsesysctl s = readish =<< lastMaybe (words s)