home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / signal / sigactio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-12  |  724 b   |  31 lines

  1. /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  3. #include <signal.h>
  4. #include <errno.h>
  5.  
  6. int
  7. sigaction(int _sig, const struct sigaction *_act, struct sigaction *_oact)
  8. {
  9.   /* note that sigaction always fails for SIGKILL */
  10.   if (_oact)
  11.   {
  12.     _oact->sa_flags = 0;
  13.     _oact->sa_handler = signal(_sig, SIG_IGN);
  14.     if (sigemptyset(&_oact->sa_mask) != 0 || _oact->sa_handler == SIG_ERR)
  15.     {
  16.       errno = EINVAL;
  17.       return -1;
  18.     }
  19.     signal(_sig, _oact->sa_handler);
  20.   }
  21.   if (_act)
  22.   {
  23.     if (signal(_sig, _act->sa_handler) == SIG_ERR)
  24.     {
  25.       errno = EINVAL;
  26.       return -1;
  27.     }
  28.   }
  29.   return 0;
  30. }
  31.