home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ldapsdk.zip / libraries / liblutil / signal.c < prev    next >
C/C++ Source or Header  |  2000-09-16  |  626b  |  34 lines

  1. /* $OpenLDAP$ */
  2. /*
  3.  * Copyright 2000 The OpenLDAP Foundation
  4.  * COPYING RESTRICTIONS APPLY.  See COPYRIGHT File in top level directory
  5.  * of this package for details.
  6.  */
  7.  
  8. #include "portable.h"
  9.  
  10. #ifdef HAVE_SIGACTION
  11. #include <ac/string.h>
  12. #include <ac/signal.h>
  13.  
  14. lutil_sig_t
  15. lutil_sigaction(int sig, lutil_sig_t func)
  16. {
  17.     struct sigaction action, oaction;
  18.  
  19.     memset( &action, '\0', sizeof(action) );
  20.  
  21.     action.sa_handler = func;
  22.     sigemptyset( &action.sa_mask );
  23. #ifdef SA_RESTART
  24.     action.sa_flags |= SA_RESTART;
  25. #endif
  26.     
  27.     if( sigaction( sig, &action, &oaction ) != 0 ) {
  28.         return NULL;
  29.     }
  30.  
  31.     return oaction.sa_handler;
  32. }
  33. #endif
  34.