home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / lib / posixsig.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-20  |  2.7 KB  |  91 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: posixsig.c,v 5.6 1993/04/21 01:16:45 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.6 $   $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.6  1993/04/21  01:16:45  syd
  18.  * SunOS 4.1.3 uses the BSD convention for signal handling in system
  19.  * calls like read. The system call resumes when the signal handler
  20.  * returns unless the SA_INTERRUPT flag is set. Thus to make elm resize
  21.  * it's window after a SIGWINCH this flag must be set.
  22.  * From: vogt@isa.de (Gerald Vogt)
  23.  *
  24.  * Revision 5.5  1992/12/24  21:44:49  syd
  25.  * Add apollo check
  26.  * From: Syd
  27.  *
  28.  * Revision 5.4  1992/12/07  03:13:08  syd
  29.  * Add code to work around SunOS and sigalrm not returning EINTR
  30.  * From: Chip, Tom, Steve, Et. Al.
  31.  *
  32.  * Revision 5.3  1992/11/07  19:30:01  syd
  33.  * Fix redefinition complaint by SCO 3.2v2.0.
  34.  * From: chip@chinacat.unicom.com (Chip Rosenthal)
  35.  *
  36.  * Revision 5.2  1992/10/27  16:08:32  syd
  37.  * Fix non ansi declaration
  38.  * From: tom@osf.org
  39.  *
  40.  * Revision 5.1  1992/10/27  01:43:56  syd
  41.  * Initial Checkin
  42.  * Moved from src/signals.c
  43.  *
  44.  *
  45.  ******************************************************************************/
  46.  
  47. /** Duplicate the old signal() call with POSIX sigaction
  48.  
  49. **/
  50.  
  51. #include "headers.h"
  52.  
  53. #ifdef POSIX_SIGNALS
  54. /*
  55.  * This routine used to duplicate the old signal() calls
  56.  */
  57. SIGHAND_TYPE
  58. #if (defined(__STDC__) && !defined(apollo))
  59. (*posix_signal(signo, fun))(int)
  60.     int signo;
  61.     SIGHAND_TYPE (*fun)(int);
  62. #else
  63. (*posix_signal(signo, fun))()
  64.     int signo;
  65.     SIGHAND_TYPE (*fun)();
  66. #endif
  67. {
  68.     struct sigaction act;    /* new signal action structure */
  69.     struct sigaction oact;  /* returned signal action structure */ 
  70.  
  71.     /*   Setup a sigaction struct */
  72.  
  73.      act.sa_handler = fun;        /* Handler is function passed */
  74.     sigemptyset(&(act.sa_mask)); /* No signal to mask while in handler */
  75.     act.sa_flags = 0;
  76. #ifdef SA_INTERRUPT
  77.     act.sa_flags |= SA_INTERRUPT;           /* SunOS */
  78. #endif
  79.  
  80.     /* use the sigaction() system call to set new and get old action */
  81.  
  82.     sigemptyset(&oact.sa_mask);
  83.     if(sigaction(signo, &act, &oact))
  84.         /* If sigaction failed return -1 */
  85.         return(SIG_ERR);
  86.     else
  87.             /* use the previous signal handler as a return value */
  88.         return(oact.sa_handler);
  89. }
  90. #endif /* POSIX_SIGNALS */
  91.