home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Networking / wu-ftpd-2.4.2b13-MIHS / src / sigfix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-03  |  2.1 KB  |  81 lines

  1. /* This software is Copyright 1997 by Stan Barber. 
  2.  *
  3.  * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  4.  * use this software as long as: there is no monetary profit gained
  5.  * specifically from the use or reproduction of this software, it is not
  6.  * sold, rented, traded or otherwise marketed, and this copyright notice is
  7.  * included prominently in any copy made. 
  8.  *
  9.  * The author make no claims as to the fitness or correctness of this software
  10.  * for any use whatsoever, and it is provided as is. Any use of this software
  11.  * is at the user's own risk. 
  12.  */
  13. #ifndef lint
  14. static char * rcsid = "$Id: sigfix.c,v 1.3 1997/01/19 02:53:22 sob Exp $";
  15. #endif
  16. #include "config.h"
  17.  
  18.  /*
  19.   * delay_signaling(), enable_signaling - delay signal delivery for a while
  20.   * 
  21.   * Original Author: Wietse Venema with small changes by Dave Kinchlea and 
  22.   * Stan Barber
  23.   */
  24.  
  25. /* 
  26.  * Some folks (notably those who do Linux hacking) say this fix is needed.
  27.  * Others (notably the FreeBSD and BSDI folks) say if isn't.
  28.  * I am making it possible to include of exclude it.
  29.  * Just define NEED_SIGFIX and you get it.
  30.  */
  31. #ifdef NEED_SIGFIX
  32. #include <sys/types.h>
  33. #include <sys/signal.h>
  34. #include <syslog.h>
  35.  
  36. static sigset_t saved_sigmask;
  37. sigset_t block_sigmask;  /* used in ftpd.c */
  38. static int delaying;
  39. static int init_done;
  40. #endif
  41. /* enable_signaling - deliver delayed signals and disable signal delay */
  42.  
  43. #ifdef __STDC__
  44. int     enable_signaling(void)
  45. #else
  46. int     enable_signaling()
  47. #endif
  48. {
  49. #ifdef NEED_SIGFIX
  50.     if (delaying != 0) {
  51.         delaying = 0;
  52.         if (sigprocmask(SIG_SETMASK, &saved_sigmask, (sigset_t *) 0) < 0) {
  53.             syslog(LOG_ERR, "sigprocmask: %m");
  54.             return (-1);
  55.         }
  56.     }
  57. #endif
  58.     return (0);
  59. }
  60.  
  61. /* delay_signaling - save signal mask and block all signals */
  62. #ifdef __STDC__
  63. int     delay_signaling(void)
  64. #else
  65. int     delay_signaling()
  66. #endif
  67. {
  68. #ifdef NEED_SIGFIX
  69.     if (delaying == 0) {
  70.         delaying = 1;
  71.         if (sigprocmask(SIG_BLOCK, &block_sigmask, &saved_sigmask) < 0) {
  72.             syslog(LOG_ERR, "sigprocmask: %m");
  73.             return (-1);
  74.         }
  75.     }
  76. #endif
  77.     return (0);
  78. }
  79.  
  80.  
  81.