]> git.sur5r.net Git - openldap/blob - libraries/liblutil/signal.c
Import changes from devel including:
[openldap] / libraries / liblutil / signal.c
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         int rc;
18         struct sigaction action, oaction;
19
20         memset( &action, '\0', sizeof(action) );
21
22         action.sa_handler = func;
23         sigemptyset( &action.sa_mask );
24 #ifdef SA_RESTART
25         action.sa_flags |= SA_RESTART;
26 #endif
27         
28         if( sigaction( sig, &action, &oaction ) != 0 ) {
29                 return NULL;
30         }
31
32         return oaction.sa_handler;
33 }
34 #endif