-- Be Careful when running this file -- spawned processes could hang up your system import System.Process import System.IO tr input = do let (cmd, args) = ("tr", ["a-z", "A-Z"]) let process = (proc cmd args){ std_in = CreatePipe , std_out = CreatePipe , close_fds = True } (Just hin, Just hout, _, _) <- createProcess process -- inject data hPutStr hin input hClose hin -- return (IO String) hGetContents hout tr' input = do let process = (proc "tr" ["a-z", "A-Z"]){ std_in = CreatePipe , std_out = CreatePipe , close_fds = True } (Just hin, Just hout, _, _) <- createProcess process -- inject data hPutStr hin input hClose hin -- return (IO String) putStr =<< hGetContents hout hClose hout test00 = mapM_ (\_ -> tr "Homebrew fork-bomb\n" >>= putStr) [0..50] test01 = mapM_ (\_ -> tr' "Homebrew fork-bomb\n") [0..50] main = test00 >> test01 >> wait where wait = do putStrLn "Press any key to quit" input <- getLine putStrLn (">>" ++ input)