# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
char raised; /* !=0 if has been raised */
void* handler; /* instance to receive call */
char safely; /* if !=0 then manage signal safely, otherwise react when raised */
char raised; /* !=0 if has been raised */
void* handler; /* instance to receive call */
char safely; /* if !=0 then manage signal safely, otherwise react when raised */
/* Receiver to all signals
If unsafe, it calls directly the Nit receiver,
/* Receiver to all signals
If unsafe, it calls directly the Nit receiver,
# var r = new MyReceiver
# r.handle_signal(sigsegv, false) # `r.receive_signal_unsafe` will be invoked on sigsegv
fun receive_signal_unsafe(signal: Int) do end
# var r = new MyReceiver
# r.handle_signal(sigsegv, false) # `r.receive_signal_unsafe` will be invoked on sigsegv
fun receive_signal_unsafe(signal: Int) do end
# If `safely`, receiver will be called when `check_signals` in invoked
# otherwise the receiver is invoked when the signal is raised, it may
# crash the Nit system but is unavoidable for unstoppable signals.
# If `safely`, receiver will be called when `check_signals` in invoked
# otherwise the receiver is invoked when the signal is raised, it may
# crash the Nit system but is unavoidable for unstoppable signals.
nit_SignalHandler_receive_signal = SignalHandler_receive_signal;
}
`}
# Set to ignore the signal
fun ignore_signal(signal: Int) `{
nit_SignalHandler_receive_signal = SignalHandler_receive_signal;
}
`}
# Set to ignore the signal
fun ignore_signal(signal: Int) `{
act.sa_handler = SIG_IGN;
sigaction(signal, &act, NULL);
act.sa_handler = SIG_IGN;
sigaction(signal, &act, NULL);
act.sa_handler = SIG_DFL;
sigaction(signal, &act, NULL);
act.sa_handler = SIG_DFL;
sigaction(signal, &act, NULL);
# Native implementation of `signal`
private fun native_kill(pid, signal: Int) `{ kill(pid, signal); `}
end
# Native implementation of `signal`
private fun native_kill(pid, signal: Int) `{ kill(pid, signal); `}
end