Programming

(OCaml) forktest.ml

steloflute 2012. 5. 28. 10:57
(* forktest (C) 2008 Kim, Taegyoon *)
open Unix

let main () =
  let pid = fork () in
    if pid = 0 then
      print_string "child\n"
    else
      (print_string "pid of the child: ";
       print_int pid;
       print_newline ())

let _ = main ()



$ more Makefile
all:
    ocamlopt.opt -o forktest unix.cmxa forktest.ml
clean:
    rm -f *.cm?
    rm -f *.o
    rm -f forktest