Created
December 30, 2019 08:50
-
-
Save ephemient/6acbfdc1e5fec57cd80410b0fdc59f50 to your computer and use it in GitHub Desktop.
A forkIO'ed thread that is reading from the TTY cannot be killed?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack script --resolver lts --package unix | |
module Main where | |
import Control.Concurrent | |
import Control.Concurrent.MVar | |
import System.Posix | |
main :: IO () | |
main = do | |
sync <- newEmptyMVar | |
threadId <- forkIO $ putMVar sync () >> fdRead stdInput 1 >>= print | |
takeMVar sync | |
putStrLn "kill?" | |
killThread threadId | |
putStrLn "kill!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment