File: delayintr.ml

package info (click to toggle)
ocaml 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,419; asm: 5,462; makefile: 3,684; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (46 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(* TEST
 include systhreads;
 readonly_files = "sigint.c";
 hassysthreads;
 not-target-windows; (* excludes mingw32/64 and msvc32/64 *)
 {
   program = "${test_build_directory}/delayintr.byte";
   setup-ocamlc.byte-build-env;
   program = "sigint";
   all_modules = "sigint.c";
   ocamlc.byte;
   program = "${test_build_directory}/delayintr.byte";
   all_modules = "delayintr.ml";
   ocamlc.byte;
   check-ocamlc.byte-output;
   run;
   check-program-output;
 }{
   program = "${test_build_directory}/delayintr.opt";
   setup-ocamlopt.byte-build-env;
   program = "sigint";
   all_modules = "sigint.c";
   ocamlopt.byte;
   program = "${test_build_directory}/delayintr.opt";
   all_modules = "delayintr.ml";
   ocamlopt.byte;
   check-ocamlopt.byte-output;
   run;
   check-program-output;
 }
*)

(* Regression test for MPR#7903 *)

let () =
  let start = Unix.gettimeofday() in
  let sighandler _ =
    let now = Unix.gettimeofday() in
    if now -. start <= 20. then begin
      print_string "Received signal early\n"; exit 0
    end else begin
      print_string "Received signal late\n"; exit 2
    end in
  Sys.set_signal Sys.sigint (Sys.Signal_handle sighandler);
  Thread.delay 30.;
  print_string "No signal received\n"; exit 4