Back to index

glibc  2.9
Functions
sigaction.c File Reference
#include <sysdep.h>
#include <errno.h>
#include <stddef.h>
#include <signal.h>

Go to the source code of this file.

Functions

int __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)

Function Documentation

int __sigaction ( int  sig,
const struct sigaction act,
struct sigaction oact 
)

Definition at line 28 of file sigaction.c.

{
  struct sigvec vec, ovec;

  if (sig <= 0 || sig >= NSIG)
    {
      __set_errno (EINVAL);
      return -1;
    }

  if (act != NULL)
    {
      vec.sv_mask = act->sa_mask;
      vec.sv_handler = act->sa_handler;
      vec.sv_flags = (((act->sa_flags & SA_ONSTACK) ? SV_ONSTACK : 0) |
                    (!(act->sa_flags & SA_RESTART) ? SV_INTERRUPT : 0));
    }

  if (__sigvec(sig, act != NULL ? &vec : (struct sigvec *) NULL, &ovec) < 0)
    return -1;

  if (oact != NULL)
    {
      oact->sa_handler = (void (*) (int)) ovec.sv_handler;
      oact->sa_mask = ovec.sv_mask;
      oact->sa_flags = (((ovec.sv_flags & SV_ONSTACK) ? SA_ONSTACK : 0) |
                     (!(ovec.sv_flags & SV_INTERRUPT) ? SA_RESTART : 0));
    }

  return 0;
}

Here is the call graph for this function: