Add a Haskell program which spawns an external process.
catseye
13 years ago
0 | module Main where | |
1 | ||
2 | import System.IO | |
3 | import System.Process | |
4 | ||
5 | cat handle = do | |
6 | eof <- hIsEOF handle | |
7 | if | |
8 | eof | |
9 | then do | |
10 | return () | |
11 | else do | |
12 | line <- hGetLine handle | |
13 | putStr ">>>" | |
14 | putStr line | |
15 | putStrLn "<<<" | |
16 | cat handle | |
17 | ||
18 | main = | |
19 | let | |
20 | cmd = (shell "ls -la *.hs"){ std_out = CreatePipe } | |
21 | in do | |
22 | (_, Just hStdout, _, proc) <- createProcess cmd | |
23 | cat hStdout | |
24 | exitCode <- waitForProcess proc | |
25 | putStrLn (show exitCode) | |
26 | return () |