signal

Gamma: Version 4.0
Prev |  | Next

# `signal`

`signal` -- defines an expression to be evaluated at an OS generated signal.

## Syntax

    signal (signal, action[, action]...)

## Arguments

`signal`

  A signal number. Normally one of the built-in signal values.

`action`

  Any Gamma or Lisp expression.

## Returns

t

## Description

This function defines an expression to be evaluated whenever the operating system generates signal number signal to this process. A signal handler may be of any complexity, though it is advisable to keep signal handlers as simple as possible. All signals and timers are blocked for the duration of the signal handler. In addition, the signal handler runs in a separate, smaller heap. If the signal handler is large, this could result in memory inefficiency. Signal handlers are typically used to ensure that the Gamma application does not exit when a signal occurs.

Table 1. Signals

Signal | Description
--- | ---
`SIGABRT` | Abort signal from the `abort()` C function.
`SIGALRM` | A timer has occurred. This signal is reserved in most operating system implementations of Gamma for use with the `after`, `at` and `every` functions. This signal is not available in Linux because it is used by the timer processing internally to Gamma. In QNX, it is the timer signal from the `alarm()` C function.
`SIGBUS` | Bus error.
`SIGCHLD` | Child died. Generated when a child process of the current process has died.
`SIGCONT` | Continue. Causes the task to restart after a SIGSTP.
`SIGFPE` | Floating point exception. Generated by an illegal mathematical function call (such as division by zero).
`SIGHUP` | Hangup. Typically generated when a terminal session disconnects.
`SIGILL` | Illegal instruction. This is an internal error.
`SIGINT` | Keyboard interrupt. Generated by `CTRL-C`.
`SIGIO` | I/O processing is required. This signal is generated when a socket or file descriptor has incoming data which must be processed.
`SIGIOT` | IOT trap. A synonym for `SIGABRT`.
`SIGKILL` | Killed. Kills the process with extreme prejudice. This signal cannot be caught.
`SIGPIPE` | Broken pipe. This occurs when a TCP/IP socket or a pipe to an inferior process is broken.
`SIGPOLL` | A pollable event. Synonym of `SIGIO`.
`SIGPWR` | Power failure. This is generated by a power monitor program to indicate that a power loss is imminent.
`SIGQUIT` | Quit.
`SIGSEGV` | Segmentation fault. This signal is generated by an attempt to access illegal memory. If this signal occurs, it represents a fault in the LISP interpreter and should be reported along with the corresponding memory address of the fault.
`SIGSTOP` | Stop execution immediately. This is used by the operating system to implement multi-tasking. This signal cannot be caught.
`SIGSYS` | Bad argument to a system routine. This happens very rarely.
`SIGTERM` | Terminated. This is generated by other programs which wish to terminate the job.
`SIGTRAP` | Trace/breakpoint trap.
`SIGTSTP` | Terminal stop. This signal is generated when the user attempts to stop a process (in operating systems which support job control).
`SIGTTIN` | Terminal input is available.
`SIGTTOU` | Terminal output is required.
`SIGURG` | Urgent. An urgent condition has occurred.
`SIGUSR1` | User-defined signal 1.
`SIGUSR2` | User-defined signal 2.
`SIGWINCH` | Window change. This is used to indicate that a change has been made to the size or position of the window in which the process is running.

## Example

        Gamma> getpid();
        10341
        Gamma> signal(SIGUSR1,#princ("Got the signal.\n"));
        t
        Gamma> kill(10341,SIGUSR1);
        Got the signal.
        t
        Gamma>

See the Starting Programs section of the Common Functions for Any Program chapter (Tutorial Two), or the Linux or QNX section of the Abstracted Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

## See Also

`after`, `at`, `every`

Prev | Home | Next
`shm_unlink` | Up | `sleep`, `usleep`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.