Chapter Contents

Previous

Next
sigaction

sigaction



Define a Signal-Handling Action

Portability: POSIX.1 conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <lcsignal.h>

int sigaction(int signum, const struct sigaction *newsig,
              struct sigaction *oldsig);

The synopsis for the POSIX implementation is

#include <signal.h>

int sigaction(int signum, const struct sigaction *newsig,
              struct sigaction *oldsig);

You should use <signal.h> only if an appropriate feature test macro has been defined.


DESCRIPTION

sigaction modifies the action associated with a signal. sigaction can be used for signals defined by SAS/C as well as USS signals. It does not require that USS be installed or available. signum is the number of the signal. signum must be a symbolic signal name defined in <signal.h> . newsig is the new action associated with a signal; if newsig is a NULL pointer, the signal action is not changed. oldsig is a pointer to a location where the action currently associated with the signal is to be stored, or NULL if this information is not needed.

The sigaction structure is defined as

struct sigaction {
      /* function that handles the signal          */
   __remote void (*sa_handler)(int);
      /* set of signals to be added to signal mask */
   sigset_t sa_mask;
      /* signal flags                              */
   int sa_flags;
};

sa_handler can be a pointer to a function, or it can have one of these values:
SIG_DFL is the default
SIG_IGN specifies that the signal should be ignored.

sa_mask is the set of signals to be added to the signal mask during handling of the signal.

sa_flags enables these flag bits (as defined by the POSIX.2 standard) to be set:
SA_NOCLDSTOP prevents a SIGCHLD signal from being issued when a child process terminates.

SAS/C also defines a number of nonstandard flags that may be set in the sa_flags word of the sigaction structure. The relevant nonstandard flags are

SA_GLOBAL
specifies that the signal handler is defined as a global signal handler; that is, one that applies to all coprocesses. (A sigaction call with SA_GLOBAL set is comparable in effect to a cosignal call.)

Note:    In an application with coprocesses, the sa_mask and sa_flags settings for a call to sigaction always apply to all coprocesses, not just to the calling coprocess. See Chapter 9, "Coprocessing Functions," in SAS/C Library Reference, Volume 2 for more details.  [cautionend]

SA_PREVIOUS
specifies that the sa_mask and sa_flags values specified by the argument to sigaction are to be ignored, and the settings specified by the previous call to sigaction are to be used. This flag is useful for defining local handlers in a coprocess without perturbing the handling defined by other coprocesses. See Chapter 9, "Coprocessing Functions," in SAS/C Library Reference, Volume 2 for more details.

SA_USRFLAG1 , SA_USRFLAG2 , ... SA_USRFLAG8
specify options to user-defined signal handlers. Their meaning, if any, is defined by the signal implementor. These flags have no meaning for any signal defined by SAS/C.


RETURN VALUE

sigaction returns 0 if it is successful and -1 if it is not successful.


EXAMPLE

See the example for sigsetjmp .


RELATED FUNCTIONS

cosignal , sigaddset , signal , sigprocmask


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.