home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / __bsd_sig.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-07  |  695 b   |  35 lines

  1. #define __USE_BSD_SIGNAL
  2.  
  3. #include <signal.h>
  4.  
  5. #undef signal
  6.  
  7. /* The `sig' bit is set if the interrupt on it
  8.  * is enabled via siginterrupt (). */
  9. extern sigset_t _sigintr;
  10.  
  11. __sighandler_t
  12. __bsd_signal (int sig, __sighandler_t handler)
  13. {
  14.   int ret;
  15.   struct sigaction action, oaction;
  16.   action.sa_handler = handler;
  17.   __sigemptyset (&action.sa_mask);
  18.   if (!__sigismember (&_sigintr, sig)) {
  19. #ifdef SA_RESTART
  20.     action.sa_flags = SA_RESTART;
  21. #else
  22.     action.sa_flags = 0;
  23. #endif
  24.   }
  25.   else {
  26. #ifdef SA_INTERRUPT
  27.     action.sa_flags = SA_INTERRUPT;
  28. #else
  29.     action.sa_flags = 0;
  30. #endif
  31.   }
  32.   ret = __sigaction (sig, &action, &oaction); 
  33.   return (ret == -1) ? SIG_ERR : oaction.sa_handler;
  34. }
  35.