[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / posix / po001 / Main.hs
1 import LibPosix
2
3 main =
4     getParentProcessID >>= \ ppid ->
5     getProcessID >>= \ pid ->
6     putStr "Parent Process ID: " >>
7     putText ppid >>
8     putStr "\nProcess ID: " >>
9     putText pid >>
10     putStr "\nforking ps uxww" >>
11     putText ppid >>
12     putChar '\n' >>
13     forkProcess >>= \ child ->
14     case child of
15         Nothing -> executeFile "ps" True ["uxww" ++ show ppid] Nothing
16         Just x -> doParent x pid
17
18 doParent cpid pid =
19     getProcessStatus True False cpid >>
20     putStr "\nChild finished.  Now exec'ing ps uxww" >>
21     putText pid >>
22     putChar '\n' >>
23     executeFile "ps" True ["uxww" ++ show pid] Nothing