This file is indexed.

/usr/share/doc/ats-lang-anairiats-examples/examples/AUP/AUP_9_1_1.dats is in ats-lang-anairiats-examples 0.2.5-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Author: Hongwei Xi (hwxi AT cs DOT bu DOT edu)
// Time: October, 2010
//
(* ****** ****** *)
//
// book: AUP (2nd edition), pages 601 - 603
// section 9.1.1: Introduction to Signals
//
(* ****** ****** *)

staload _(*anon*) = "prelude/DATS/pointer.dats"

(* ****** ****** *)

staload "libc/SATS/fcntl.sats"
staload "libc/SATS/signal.sats"
staload "libc/SATS/stdio.sats" // perror
staload "libc/SATS/stdlib.sats" // _Exit
staload "libc/SATS/unistd.sats"

(* ****** ****** *)

fun handler
  (sgn: signum_t): void = () where {
  val (pf_stdout | ()) = stdout_fildes_view_get ()
  val msg = "Got signal\n"
  val nmsg = string_length (msg)
  val (pf, fpf | p_msg) = __cast (msg) where {
    extern castfn __cast {n:nat}
      (x: string n):<> [l:addr] (bytes(n) @ l, bytes(n) @ l -<lin,prf> void | ptr l)
    // end of [extern]
  } // end of [val]
  val _err = write_err // HX: [printf] is unsafe!!!
    (pf_stdout | STDOUT_FILENO, !p_msg, nmsg)
  prval () = fpf (pf)
  val () = stdout_fildes_view_set (pf_stdout | (*none*))
  val () = _Exit (EXIT_FAILURE)
} // end of [val]

(* ****** ****** *)

implement
main () = () where {
  var act: sigaction
  val () = ptr_zero<sigaction> (act)
  val () = act.sa_handler := (sighandler)handler
  val err = sigaction_null (SIGINT, act)
  val () = if err < 0 then (perror "sigaction"; exit (EXIT_FAILURE))
  var i: int
  val () = for
    (i := 1; ; i := i+1) let
    val _leftover = sleep (1); val () = printf ("%d\n", @(i))
  in
    // nothing
  end // end of [val]
} // end of [main]

(* ****** ****** *)

(* end of [AUP_9_1_1.dats] *)