Removed $Id$ everywhere.
[virt-top.git] / virt-top / virt_top_main.ml
1 (* 'top'-like tool for libvirt domains.
2  *
3  * Just contains the main function.
4  *)
5
6 open Curses
7
8 open Virt_top
9
10 (* Note: make sure we catch any exceptions and clean up the display.
11  *
12  * Note (2): make sure all exit paths call the GC so that we can check
13  * that all allocated resources are being counted properly (by running
14  * the program under --debug ...).
15  *)
16 let error =
17   let setup = start_up () in
18
19   try
20     main_loop setup;
21     endwin ();
22     false
23   with
24   | Libvirt.Virterror err ->
25       endwin ();
26       prerr_endline (Libvirt.Virterror.to_string err);
27       true
28   | exn ->
29       endwin ();
30       prerr_endline ("Error: " ^ Printexc.to_string exn);
31       true
32
33 let () =
34   Gc.compact (); (* See note above. *)
35
36   exit (if error then 1 else 0)