- _ <- forever $
- -- This thread (the one executing main) doesn't do anything,
- -- but when it terminates, so do all the threads we forked.
- -- As a result, we need to keep this thread on life support.
- thread_sleep (heartbeat cfg)
+ let run_program = (mapM_ -- Execute run on each username in a new thread.
+ (forkIO . run_curried)
+ (get_usernames (usernames cfg)))
+ >>
+ -- This thread (the one executing main) doesn't do
+ -- anything, but when it terminates, so do all the
+ -- threads we forked. As a result, we need to
+ -- keep this thread on life support. If we were
+ -- asked to daemonize, do that; otherwise just run
+ -- the thing.
+ forever (thread_sleep (heartbeat cfg))
+
+ if (daemonize cfg)
+ then try_daemonize cfg run_program
+ else run_program