www.delorie.com/gnu/docs/guile/guile_419.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

38.8 Signals

Procedures to raise, handle and wait for signals.

Scheme Procedure: kill pid sig
C Function: scm_kill (pid, sig)
Sends a signal to the specified process or group of processes.

pid specifies the processes to which the signal is sent:

pid greater than 0
The process whose identifier is pid.
pid equal to 0
All processes in the current process group.
pid less than -1
The process group whose identifier is -pid
pid equal to -1
If the process is privileged, all processes except for some special system processes. Otherwise, all processes with the current effective user ID.

sig should be specified using a variable corresponding to the Unix symbolic name, e.g.,

Variable: SIGHUP
Hang-up signal.

Variable: SIGINT
Interrupt signal.

Scheme Procedure: raise sig
C Function: scm_raise (sig)
Sends a specified signal sig to the current process, where sig is as described for the kill procedure.

Scheme Procedure: sigaction signum [handler [flags]]
C Function: scm_sigaction (signum, handler, flags)
Install or report the signal handler for a specified signal.

signum is the signal number, which can be specified using the value of variables such as SIGINT.

If action is omitted, sigaction returns a pair: the CAR is the current signal hander, which will be either an integer with the value SIG_DFL (default action) or SIG_IGN (ignore), or the Scheme procedure which handles the signal, or #f if a non-Scheme procedure handles the signal. The CDR contains the current sigaction flags for the handler.

If action is provided, it is installed as the new handler for signum. action can be a Scheme procedure taking one argument, or the value of SIG_DFL (default action) or SIG_IGN (ignore), or #f to restore whatever signal handler was installed before sigaction was first used. Flags can optionally be specified for the new handler (SA_RESTART will always be added if it's available and the system is using restartable system calls.) The return value is a pair with information about the old handler as described above.

This interface does not provide access to the "signal blocking" facility. Maybe this is not needed, since the thread support may provide solutions to the problem of consistent access to data structures.

Scheme Procedure: restore-signals
C Function: scm_restore_signals ()
Return all signal handlers to the values they had before any call to sigaction was made. The return value is unspecified.

Scheme Procedure: alarm i
C Function: scm_alarm (i)
Set a timer to raise a SIGALRM signal after the specified number of seconds (an integer). It's advisable to install a signal handler for SIGALRM beforehand, since the default action is to terminate the process.

The return value indicates the time remaining for the previous alarm, if any. The new value replaces the previous alarm. If there was no previous alarm, the return value is zero.

Scheme Procedure: pause
C Function: scm_pause ()
Pause the current process (thread?) until a signal arrives whose action is to either terminate the current process or invoke a handler procedure. The return value is unspecified.

Scheme Procedure: sleep i
C Function: scm_sleep (i)
Wait for the given number of seconds (an integer) or until a signal arrives. The return value is zero if the time elapses or the number of seconds remaining otherwise.

Scheme Procedure: usleep i
C Function: scm_usleep (i)
Sleep for I microseconds. usleep is not available on all platforms.

Scheme Procedure: setitimer which_timer interval_seconds interval_microseconds value_seconds value_microseconds
C Function: scm_setitimer (which_timer, interval_seconds, interval_microseconds, value_seconds, value_microseconds)
Set the timer specified by which_timer according to the given interval_seconds, interval_microseconds, value_seconds, and value_microseconds values.

Return information about the timer's previous setting. Errors are handled as described in the guile info pages under "POSIX Interface Conventions".

The timers available are: ITIMER_REAL, ITIMER_VIRTUAL, and ITIMER_PROF.

The return value will be a list of two cons pairs representing the current state of the given timer. The first pair is the seconds and microseconds of the timer it_interval, and the second pair is the seconds and microseconds of the timer it_value.

Scheme Procedure: getitimer which_timer
C Function: scm_getitimer (which_timer)
Return information about the timer specified by which_timer Errors are handled as described in the guile info pages under "POSIX Interface Conventions".

The timers available are: ITIMER_REAL, ITIMER_VIRTUAL, and ITIMER_PROF.

The return value will be a list of two cons pairs representing the current state of the given timer. The first pair is the seconds and microseconds of the timer it_interval, and the second pair is the seconds and microseconds of the timer it_value.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003