Preemption

A process can be stopped when an event is received using the do/until construct (note that it is not a loop construct).

signal kill;;

let process p =
  do
    for i = 1 to max_int do
      print_int i;
      print_newline ();
      pause
    done
  until kill done ;;

#run p;;

emit kill;;