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