git @ Cat's Eye Technologies The-Dipple / a09cb19
Add a Haskell program which spawns an external process. catseye 13 years ago
1 changed file(s) with 27 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
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 ()