home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / elm-2.4-pl20.tar.Z / elm-2.4-pl20.tar / lib / posixsig.c < prev    next >
C/C++ Source or Header  |  1993-01-12  |  2KB  |  86 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: posixsig.c,v 5.5 1992/12/24 21:44:49 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.5 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: posixsig.c,v $
  17.  * Revision 5.5  1992/12/24  21:44:49  syd
  18.  * Add apollo check
  19.  * From: Syd
  20.  *
  21.  * Revision 5.4  1992/12/07  03:13:08  syd
  22.  * Add code to work around SunOS and sigalrm not returning EINTR
  23.  * From: Chip, Tom, Steve, Et. Al.
  24.  *
  25.  * Revision 5.3  1992/11/07  19:30:01  syd
  26.  * Fix redefinition complaint by SCO 3.2v2.0.
  27.  * From: chip@chinacat.unicom.com (Chip Rosenthal)
  28.  *
  29.  * Revision 5.2  1992/10/27  16:08:32  syd
  30.  * Fix non ansi declaration
  31.  * From: tom@osf.org
  32.  *
  33.  * Revision 5.1  1992/10/27  01:43:56  syd
  34.  * Initial Checkin
  35.  * Moved from src/signals.c
  36.  *
  37.  *
  38.  ******************************************************************************/
  39.  
  40. /** Duplicate the old signal() call with POSIX sigaction
  41.  
  42. **/
  43.  
  44. #include "headers.h"
  45.  
  46. #ifdef POSIX_SIGNALS
  47. /*
  48.  * This routine used to duplicate the old signal() calls
  49.  */
  50. SIGHAND_TYPE
  51. #if (defined(__STDC__) && !defined(apollo))
  52. (*posix_signal(signo, fun))(int)
  53.     int signo;
  54.     SIGHAND_TYPE (*fun)(int);
  55. #else
  56. (*posix_signal(signo, fun))()
  57.     int signo;
  58.     SIGHAND_TYPE (*fun)();
  59. #endif
  60. {
  61.     struct sigaction act;    /* new signal action structure */
  62.     struct sigaction oact;  /* returned signal action structure */ 
  63.  
  64.     /*   Setup a sigaction struct */
  65.  
  66.      act.sa_handler = fun;        /* Handler is function passed */
  67.     sigemptyset(&(act.sa_mask)); /* No signal to mask while in handler */
  68.     act.sa_flags = 0;
  69.     if (signo == SIGALRM) {
  70. #ifdef SA_INTERRUPT
  71.                 act.sa_flags |= SA_INTERRUPT;           /* SunOS */
  72. #endif
  73.         }
  74.     
  75.     /* use the sigaction() system call to set new and get old action */
  76.  
  77.     sigemptyset(&oact.sa_mask);
  78.     if(sigaction(signo, &act, &oact))
  79.         /* If sigaction failed return -1 */
  80.         return(SIG_ERR);
  81.     else
  82.             /* use the previous signal handler as a return value */
  83.         return(oact.sa_handler);
  84. }
  85. #endif /* POSIX_SIGNALS */
  86.