Some parts of virt-v2v have exit cleanup handlers for things like
deleting temporary files. These run on failures, but don't run if the
user presses ^C or a signal is received from a wrapper process.
This commit adds a signal handler which calls exit (hence exit
handlers) on SIGINT or SIGQUIT.
Note that OCaml signal handlers are only called at safe points such as
before system calls or allocation, so this is relatively safe.
---
v2v/v2v.ml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index f494defcf..83a101d67 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -48,6 +48,11 @@ type mpstat = {
let () = Random.self_init ()
let rec main () =
+ (* Install a signal handler to call exit handlers if the user presses ^C. *)
+ let do_sigint _ = exit 1 in
+ Sys.set_signal Sys.sigint (Sys.Signal_handle do_sigint);
+ Sys.set_signal Sys.sigquit (Sys.Signal_handle do_sigint);
+
(* Handle the command line. *)
let cmdline, input, output = parse_cmdline () in
--
2.13.2