Permalink
Browse files

Use threadDelay instead

  • Loading branch information...
bneijt committed Jul 25, 2014
1 parent 5e63582 commit fb129aa963c9ec5118836c9b4d4a0fc0eee2767e
Showing with 11 additions and 11 deletions.
  1. +1 −1 after.cabal
  2. +10 −10 src/After.hs
@@ -20,6 +20,6 @@ executable after
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.8, options ==1.*, hinotify ==0.3.*
build-depends: base >=4.7 && <4.8, options ==1.*, directory ==1.2.*
hs-source-dirs: src
default-language: Haskell2010
@@ -1,18 +1,18 @@
module After where

import System.INotify
import Control.Concurrent
import System.Directory

justShowAndUnlock :: MVar String -> Event -> IO()
justShowAndUnlock mvar event = do
putStrLn (show event)
putMVar mvar "Yep, this is happening"
halfASecondInMicroseconds = 500000

afterPid :: String -> IO ()
afterPid pid = do
inotifyHandle <- initINotify
unockedAfter <- newEmptyMVar
watchHandle <- addWatch inotifyHandle [DeleteSelf, MoveSelf, OnlyDir] ("/proc/" ++ pid) (justShowAndUnlock unockedAfter)
seen <- takeMVar unockedAfter
putStrLn seen
fileExists <- doesDirectoryExist ("/proc/" ++ pid)
if fileExists
then do
threadDelay halfASecondInMicroseconds
afterPid pid
else return ()



0 comments on commit fb129aa

Please sign in to comment.