signal

Specifies an action to take place when certain conditions are detected (signaled) while a program executes.

Library:LibC
Classification:ANSI
Service:Signal Services

Syntax

  #include <signal.h> 
   
  void (*signal (
     int     sig,   
     void   (*func) (
        int))) 
     (int); 
  

Parameters

sig

(IN) Specifies the condition being signaled. See Section 5.1, Standard Signals.

func

(IN) Points to the function to be called when the signaled condition occurs.

Return Values

Returns the previous setting if successful or SIG_ERR if a failure occurred.

Remarks

The signal function is used to specify an action to take place when certain conditions are detected while a program executes.

The func parameter is used to specify an action to take for the specified condition. When the func parameter is a function name, that function is called equivalently to the following code sequence.

     signal (sig, SIG_DFL); 
     (*func) (sig); 
  

The function specified by the func parameter can terminate the program by calling the exit, _exit, pthread_exit, or abort functions. It can also call the longjmp function or it can return. Because the next signal is handled with default handling, the program must again call signal if it is desired to handle the next condition of the type that has been signaled.

A registered SIGTERM signal handler is on a per-NLM basis. You only have to register your SIGTERM handler once for the NLM.

Signals can be set to the following conditions:

Setting

Description

SIG_IGN

Causes the indicated condition to be ignored.

SIG_DFL

Causes the default action for the condition to occur. In POSIX semantics, this is the default action for all signals.

A program can generate a condition by calling the raise function.

The default action for the SIGABRT action is to call abort. The default action for the other conditions is to ignore the condition.

The signal function supports two types of behavior.

  • If POSIX semantics are not being used, only SIGTERM, SIGABRT, and SIGINT are supported. All other signal values are ignored. The exit, _exit, NXThreadExit, and abort functions cannot be called from the context of a SIGTERM handler, or the server console ceases to function.

  • If POSIX semantics are being used, see Section 5.1, Standard Signals for the list of supported signals. The exit, _exit, pthread_exit, and abort functions can be called from the context of any signal handler.

See Also