ni_nitdoc: cleaned visibility in model redef
[nit.git] / lib / signals / signals.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Module to manage standard C signals
18 module signals
19
20 # Receives the callback from system when a given signal arise
21 interface SignalHandler
22 # Called on any signal received
23 fun receive_signal( signal : Int ) is abstract
24
25 # Called on any unsafe signal received
26 fun receive_signal_unsafe( signal : Int ) is abstract
27
28 # Set the receiver as the handler of the signal
29 # If safely, receiver will be called when check_signals in invoked
30 # otherwise the receiver is invoked when the signal is raised, it may
31 # crash the Nit system but is unavoidable for unstoppable signals
32 fun handle_signal( signal : Int, safely : Bool ) is extern import
33 receive_signal
34
35 # Set to ignore the signal
36 fun ignore_signal( signal : Int ) is extern
37
38 # Set default action for the signal
39 fun default_signal( signal : Int ) is extern
40
41 fun sigalarm : Int do return 14
42 fun sighup : Int do return 1
43 fun sigint : Int do return 2
44 fun sigkill : Int do return 9
45 fun sigpipe : Int do return 13
46 fun sigterm : Int do return 15
47 fun sigabrt : Int do return 6
48 fun sigfpe : Int do return 8
49 fun sigquit : Int do return 3
50 fun sigsegv : Int do return 11
51 end
52
53 redef interface Object
54
55 # Check signals for safe operation
56 # will callback receiver of raised signals
57 # can callback any instance of SignalHandler, not just this one
58 protected fun check_signals : Bool is extern import SignalHandler::receive_signal
59
60 # Set alarm signal
61 # can callback any instance of SignalHandler, not just this one
62 protected fun set_alarm( sec : Int ) is extern
63 end