00001 /*- 00002 * See the file LICENSE for redistribution information. 00003 * 00004 * Copyright (c) 2000 00005 * Sleepycat Software. All rights reserved. 00006 */ 00007 00008 #ifdef HAVE_CONFIG_H 00009 #include "config.h" 00010 #endif /* HAVE_CONFIG_H */ 00011 00012 #include <sys/types.h> 00013 #include <signal.h> 00014 00015 extern "C" { 00016 #include "db_int.h" 00017 #include "common_ext.h" 00018 } 00019 00020 static int interrupt; 00021 static void onint(int); 00022 00023 /* 00024 * onint -- 00025 * Interrupt signal handler. 00026 */ 00027 static void onint(int signo) 00028 { 00029 if ((interrupt = signo) == 0) 00030 interrupt = SIGINT; 00031 } 00032 00033 void __db_util_siginit() 00034 { 00035 /* 00036 * Initialize the set of signals for which we want to clean up. 00037 * Generally, we try not to leave the shared regions locked if 00038 * we can. 00039 */ 00040 #ifdef SIGHUP 00041 (void) signal(SIGHUP, onint); 00042 #endif 00043 (void) signal(SIGINT, onint); 00044 #ifdef SIGPIPE 00045 (void) signal(SIGPIPE, onint); 00046 #endif 00047 (void) signal(SIGTERM, onint); 00048 } 00049 00050 int __db_util_interrupted() 00051 { 00052 return (interrupt != 0); 00053 } 00054 00055 void __db_util_sigresend() 00056 { 00057 /* Resend any caught signal. */ 00058 if (__db_util_interrupted != 0) { 00059 (void) signal(interrupt, SIG_DFL); 00060 (void) raise(interrupt); 00061 /* NOTREACHED */ 00062 } 00063 }