Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

util_sig.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: util_sig.c,v 12.1 2005/06/16 20:20:55 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 
00015 #include <signal.h>
00016 #endif
00017 
00018 #include "db_int.h"
00019 
00020 static int      interrupt;
00021 static void     onint __P((int));
00022 
00023 /*
00024  * onint --
00025  *      Interrupt signal handler.
00026  */
00027 static void
00028 onint(signo)
00029         int signo;
00030 {
00031         if ((interrupt = signo) == 0)
00032                 interrupt = SIGINT;
00033 }
00034 
00035 /*
00036  * __db_util_siginit --
00037  *
00038  * PUBLIC: void __db_util_siginit __P((void));
00039  */
00040 void
00041 __db_util_siginit()
00042 {
00043         /*
00044          * Initialize the set of signals for which we want to clean up.
00045          * Generally, we try not to leave the shared regions locked if
00046          * we can.
00047          */
00048 #ifdef SIGHUP
00049         (void)signal(SIGHUP, onint);
00050 #endif
00051         (void)signal(SIGINT, onint);
00052 #ifdef SIGPIPE
00053         (void)signal(SIGPIPE, onint);
00054 #endif
00055         (void)signal(SIGTERM, onint);
00056 }
00057 
00058 /*
00059  * __db_util_interrupted --
00060  *      Return if interrupted.
00061  *
00062  * PUBLIC: int __db_util_interrupted __P((void));
00063  */
00064 int
00065 __db_util_interrupted()
00066 {
00067         return (interrupt != 0);
00068 }
00069 
00070 /*
00071  * __db_util_sigresend --
00072  *
00073  * PUBLIC: void __db_util_sigresend __P((void));
00074  */
00075 void
00076 __db_util_sigresend()
00077 {
00078         /* Resend any caught signal. */
00079         if (interrupt != 0) {
00080                 (void)signal(interrupt, SIG_DFL);
00081                 (void)raise(interrupt);
00082                 /* NOTREACHED */
00083         }
00084 }

Generated on Sun Dec 25 12:14:17 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2