| File system | categories Platform Signal Handling |
Using XL Claire Debugging |
Starting with XL CLAIRE we can install an Interrupt Service Routine written in CLAIRE for a particular signal. Signals, in XL CLAIRE, are not true asynchronous event since they are always caught by the Kernel as a first step and redistributed to the meta code from an appropriate execution point (necessary to preserve memory integrity) : the meta handling is always performed in the program execution flow (i.e. not in the stack of the signal handler) so that the code of the handler may be arbitrary complex.
The signal interface is very similar to C interface, we use signal(sig:signal_handler, p:property) to install a signal handler :
| user_interrupt() : void -> error("User interrupt") (signal(SIGUSR1, user_interrupt)) (raise(SIGUSR1)) // would throw the error above |
| (signal(SIGUSR1, SIG_DFL)) |
| (signal(SIGUSR1, SIG_IGN)) |
However, SIGINT is handled in a particular way (SIGINT is on most UNIX raised with the keyboard when the user types ^C - Control + C). The SIGINT handler, when set to SIG_DFL (default), throws a user interrupt error such to abort the current computation and come back to the interpreter. If, additionally, the debugger is active, SIGINT would behave as a breakpoint.
| categories | Signal Handling | normal dispatch | [XL] Core method |
getitimer returns the current values for timer it (i.e. the interval and the value).
| categories | Signal Handling | open | [XL] Core class |
UNIX timer interface can handle 3 kind of timers:
| categories | Signal Handling | normal dispatch | [XL] Kernel method |
send the signal sig to the process with pid p.
| categories | Signal Handling | normal dispatch | [XL] Core method |
raise the given signal to the calling process
| categories | Signal Handling | normal dispatch | [XL] Core method |
setitimer sets a timer to the specified interval / value (in milliseconds). If value is non-zero, it indicates the time to the next timer expiration (at reload). If interval is non-zero, it specifies a value to be used in reloading value when the timer expires. Setting interval/value to 0/0 disables a timer. Setting interval to 0 causes a timer to be disabled after its next expiration (assuming value is non-zero). For instance we could implement a timeout as follow :
| timeout() : void -> error("Time out !") (signal(SIGALRM, timeout)) (setitimer(ITIMER_REAL, 0, 10000)) |
| categories | Signal Handling | normal dispatch | [XL] Core method |
sigblock adds a set of signal to the process signal mask.
| categories | Signal Handling | normal dispatch | [XL] Core method |
Install a signal handler for the given signal_handler. A restriction p should exists with the domain void. signal returns the old property associated with the signal handler. One may use special values for the handler p:
| categories | Signal Handling | open | [XL] Core class |
In claire signals are named objects. signal handling is system dependent and a signal_handler instance may not correspond to a supported signal in which case its value signo will be set to -1.
| categories | Signal Handling | normal dispatch | [XL] Core method |
sigpending returns the set of signals that are currently blocked from delivery, i.e. the process has been signaled but the delivery is blocked until the signal is unblocked (sigunblock).
| categories | Signal Handling | normal dispatch | [XL] Core method |
sigprocmask returns the set of signal that are part of the process signal mask, that is the set of signal that the subsystem blocks from delivery.
| categories | Signal Handling | normal dispatch | [XL] Core method |
sigsetmask sets the set of signal for the process signal mask, that is the set of signal that the subsystem blocks from delivery.
| categories | Signal Handling | normal dispatch | [XL] Core method |
sigsuspend temporarily changes the process signal mask to the set sigs, and then wait for a signal to arrive; on return the previous set of masked signals is restored. The signal mask set is usually empty to indicate that all signals are to be unblocked for the duration of the call.
| categories | Signal Handling | normal dispatch | [XL] Core method |
sigunblock removes a set of signal to the process signal mask.