ssignal or gsignal Subroutine

Purpose

Implements a software signal facility.

Library

Standard C Library (libc.a)

Syntax

#include <signal.h>
void (*ssignal ( Signal,  Action))( )
int Signal;
void (*Action)( );
int gsignal (Signal)
int Signal;

Description

Attention: Do not use the ssignal or gsignal subroutine in a multithreaded environment.

The ssignal and gsignal subroutines implement a software facility similar to that of the signal and kill subroutines. However, there is no connection between the two facilities. User programs can use the ssignal and gsignal subroutines to handle exceptional processing within an application. The signal subroutine and related subroutines handle system-defined exceptions.

The software signals available are associated with integers in the range 1 through 16. Other values are reserved for use by the C library and should not be used.

The ssignal subroutine associates the procedure specified by the Action parameter with the software signal specified by the Signal parameter. The gsignal subroutine raises the Signal, causing the procedure specified by the Action parameter to be taken.

The Action parameter is either a pointer to a user-defined subroutine, or one of the constants SIG_DFL (default action) and SIG_IGN (ignore signal). The ssignal subroutine returns the procedure that was previously established for that signal. If no procedure was established before, or if the signal number is illegal, then the ssignal subroutine returns the value of SIG_DFL.

The gsignal subroutine raises the signal specified by the Signal parameter by doing the following:

  • If the procedure for the Signal parameter is SIG_DFL, the gsignal subroutine returns a value of 0 and takes no other action.
  • If the procedure for the Signal parameter is SIG_IGN, the gsignal subroutine returns a value of 1 and takes no other action.
  • If the procedure for the Signal parameter is a subroutine, the Action value is reset to the SIG_DFL procedure and the subroutine is called, with the Signal value passed as its parameter. The gsignal subroutine returns the value returned by the signal-handling routine.
  • If the Signal parameter specifies an illegal value or if no procedure is specified for that signal, the gsignal subroutine returns a value of 0 and takes no other action.

Parameters

Item Description
Signal Specifies a signal.
Action Specifies a procedure.