signal.c

Go to the documentation of this file.
00001 /* SYSVR4 and ANSI compatible signal(2). */
00002 
00003 #include <lib.h>
00004 #define sigaction       _sigaction
00005 #define sigemptyset     _sigemptyset
00006 #include <signal.h>
00007 
00008 PUBLIC sighandler_t signal(sig, disp)
00009 int sig;                        /* signal number */
00010 sighandler_t disp;              /* signal handler, or SIG_DFL, or SIG_IGN */
00011 {
00012   struct sigaction sa, osa;
00013 
00014   if (sig <= 0 || sig > _NSIG || sig == SIGKILL) {
00015         errno = EINVAL;
00016         return(SIG_ERR);
00017   }
00018   sigemptyset(&sa.sa_mask);
00019 
00020 #ifdef WANT_UNRELIABLE_SIGNALS
00021   /* Allow the signal being handled to interrupt the signal handler. */
00022   sa.sa_flags = SA_NODEFER;
00023 
00024   /* When signal is caught, reset signal handler to SIG_DFL for all but
00025    * SIGILL and SIGTRAP.
00026    */
00027   if (sig != SIGILL && sig != SIGTRAP) sa.sa_flags |= SA_RESETHAND;
00028 #else
00029   sa.sa_flags = 0;
00030 #endif
00031 
00032   sa.sa_handler = disp;
00033   if (sigaction(sig, &sa, &osa) < 0) return(SIG_ERR);
00034   return(osa.sa_handler);
00035 }

Generated on Fri Apr 14 22:56:56 2006 for minix by  doxygen 1.4.6