summaryrefslogtreecommitdiff
path: root/ocaml-binary-annot/debugger/exec.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml-binary-annot/debugger/exec.ml')
-rw-r--r--ocaml-binary-annot/debugger/exec.ml53
1 files changed, 53 insertions, 0 deletions
diff --git a/ocaml-binary-annot/debugger/exec.ml b/ocaml-binary-annot/debugger/exec.ml
new file mode 100644
index 0000000000..1ea165978f
--- /dev/null
+++ b/ocaml-binary-annot/debugger/exec.ml
@@ -0,0 +1,53 @@
+(***********************************************************************)
+(* *)
+(* Objective Caml *)
+(* *)
+(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *)
+(* Objective Caml port by John Malecki and Xavier Leroy *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the Q Public License version 1.0. *)
+(* *)
+(***********************************************************************)
+
+(* $Id$ *)
+
+(* Handling of keyboard interrupts *)
+
+let interrupted = ref false
+
+let is_protected = ref false
+
+let break signum =
+ if !is_protected
+ then interrupted := true
+ else raise Sys.Break
+
+let _ =
+ match Sys.os_type with
+ "Win32" -> ()
+ | _ ->
+ Sys.set_signal Sys.sigint (Sys.Signal_handle break);
+ Sys.set_signal Sys.sigpipe (Sys.Signal_handle (fun _ -> raise End_of_file))
+
+let protect f =
+ if !is_protected then
+ f ()
+ else begin
+ is_protected := true;
+ if not !interrupted then
+ f ();
+ is_protected := false;
+ if !interrupted then begin interrupted := false; raise Sys.Break end
+ end
+
+let unprotect f =
+ if not !is_protected then
+ f ()
+ else begin
+ is_protected := false;
+ if !interrupted then begin interrupted := false; raise Sys.Break end;
+ f ();
+ is_protected := true
+ end