REF use when luke

This commit is contained in:
Nathan Dwarshuis 2020-03-25 16:34:38 -04:00
parent 0ba68a457b
commit e8cf056301
1 changed files with 4 additions and 6 deletions

View File

@ -97,9 +97,7 @@ waitAndKill tag pid = waitUntilExit pidDir
withUniquePid :: WatchedPIDs -> Pid -> IO () -> IO () withUniquePid :: WatchedPIDs -> Pid -> IO () -> IO ()
withUniquePid curPIDs pid f = do withUniquePid curPIDs pid f = do
pids <- readMVar curPIDs pids <- readMVar curPIDs
if pid `elem` pids unless (pid `elem` pids) $ do
then return ()
else do
modifyMVar_ curPIDs (return . (pid:)) modifyMVar_ curPIDs (return . (pid:))
f f
modifyMVar_ curPIDs (return . filter (/=pid)) modifyMVar_ curPIDs (return . filter (/=pid))