Ticket #227: MyPipe2.2.hs

File MyPipe2.2.hs, 390 bytes (added by fergus, 16 years ago)
Line 
1import Posix(popen)
2
3run_command_in_pipe :: FilePath -> [String] -> Maybe String -> IO ()
4run_command_in_pipe cmd args maybe_stdin = 
5        do      (stdout, stderr, pid) <- Posix.popen cmd args maybe_stdin
6                putStrLn $ "stdout: " ++ stdout
7                putStrLn $ "stderr: " ++ stderr
8                putStrLn $ "pid: " ++ show pid
9
10main = do
11        let input = replicate 4097 '\n'
12        run_command_in_pipe "cat" [] (Just input)