/usr/share/doc/mlton/examples/signals.sml is in mlton-doc 20100608-5.
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 | structure List =
struct
open List
fun foreach (l, f) = app f l
end
structure Process = Posix.Process
open Process Posix.Signal MLton.Signal
fun print s = let open TextIO
in output (stdErr, s)
; output (stdErr, "\n")
end
val sleep = sleep o Time.fromSeconds
val _ =
case fork () of
NONE =>
let
val _ =
List.foreach
([(hup, "Got a hup."),
(int, "You can't int me you loser."),
(term, "Don't even try to term me.")],
fn (signal, msg) =>
setHandler (signal, Handler.simple (fn () => print msg)))
fun loop' () = (sleep 1; loop' ())
in loop' ()
end
| SOME pid =>
let
fun signal s = Process.kill (K_PROC pid, s)
in
sleep 1
; print "sending 1"
; List.foreach ([hup, int, term], signal)
; sleep 3
; print "sending 2"
; List.foreach ([hup, int], signal)
; sleep 3
; print "sending 3"
; signal kill
; wait ()
end
|