[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / posix / po001 / Main.hs
diff --git a/ghc/misc/examples/posix/po001/Main.hs b/ghc/misc/examples/posix/po001/Main.hs
new file mode 100644 (file)
index 0000000..db10bab
--- /dev/null
@@ -0,0 +1,23 @@
+import LibPosix
+
+main =
+    getParentProcessID >>= \ ppid ->
+    getProcessID >>= \ pid ->
+    putStr "Parent Process ID: " >>
+    putText ppid >>
+    putStr "\nProcess ID: " >>
+    putText pid >>
+    putStr "\nforking ps uxww" >>
+    putText ppid >>
+    putChar '\n' >>
+    forkProcess >>= \ child ->
+    case child of
+       Nothing -> executeFile "ps" True ["uxww" ++ show ppid] Nothing
+       Just x -> doParent x pid
+
+doParent cpid pid =
+    getProcessStatus True False cpid >>
+    putStr "\nChild finished.  Now exec'ing ps uxww" >>
+    putText pid >>
+    putChar '\n' >>
+    executeFile "ps" True ["uxww" ++ show pid] Nothing