2000-07-22 08:37:51 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-26 07:17:08 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2008-01-08 08:19:56 +08:00
|
|
|
* Copyright 1998-2008 The OpenLDAP Foundation.
|
2003-11-26 07:17:08 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
2000-07-22 08:37:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
2000-08-22 00:48:11 +08:00
|
|
|
#include <ac/string.h>
|
2000-07-22 08:37:51 +08:00
|
|
|
#include <ac/signal.h>
|
|
|
|
|
|
|
|
lutil_sig_t
|
|
|
|
lutil_sigaction(int sig, lutil_sig_t func)
|
|
|
|
{
|
|
|
|
struct sigaction action, oaction;
|
|
|
|
|
|
|
|
memset( &action, '\0', sizeof(action) );
|
|
|
|
|
|
|
|
action.sa_handler = func;
|
|
|
|
sigemptyset( &action.sa_mask );
|
|
|
|
#ifdef SA_RESTART
|
2000-09-14 05:49:08 +08:00
|
|
|
action.sa_flags |= SA_RESTART;
|
2000-07-22 08:37:51 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if( sigaction( sig, &action, &oaction ) != 0 ) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return oaction.sa_handler;
|
|
|
|
}
|
|
|
|
#endif
|