Changeset 5166
- Timestamp:
- Feb 28, 2008, 5:51:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/main.c
r5160 r5166 67 67 /* interval in milliseconds to check for stopped torrents and update display */ 68 68 #define EXIT_CHECK_INTERVAL 500 69 70 /* number of fatal signals required to cause an immediate exit */71 #define SIGCOUNT_MAX 372 69 73 70 #if GTK_CHECK_VERSION(2,8,0) … … 124 121 static GtkUIManager * myUIManager = NULL; 125 122 126 static sig_atomic_t global_sigcount = 0;127 128 123 static gboolean 129 124 sendremote( GList * files, gboolean sendquit ); … … 155 150 static gboolean 156 151 updatemodel(gpointer gdata); 157 158 static void159 setupsighandlers(void);160 static void161 fatalsig(int sig);162 152 163 153 struct counts_data … … 233 223 cbdata->minimized = ( event->new_window_state & GDK_WINDOW_STATE_ICONIFIED ) ? 1 : 0; 234 224 } 225 } 226 227 static sig_atomic_t global_sigcount = 0; 228 229 static void 230 fatalsig( int sig ) 231 { 232 static const int SIGCOUNT_MAX = 3; /* revert to default handler after this many */ 233 234 if( ++global_sigcount >= SIGCOUNT_MAX ) 235 { 236 signal( sig, SIG_DFL ); 237 raise( sig ); 238 } 239 } 240 241 242 static void 243 setupsighandlers( void ) 244 { 245 #ifdef G_OS_WIN32 246 const int sigs[] = { SIGINT, SIGTERM }; 247 #else 248 const int sigs[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM }; 249 #endif 250 guint i; 251 252 for( i=0; i<G_N_ELEMENTS(sigs); ++i ) 253 signal( sigs[i], fatalsig ); 235 254 } 236 255 … … 1134 1153 updatemodel( data ); 1135 1154 } 1136 1137 1138 static void1139 setupsighandlers(void) {1140 int sigs[] = {SIGHUP, SIGINT, SIGQUIT, SIGTERM};1141 struct sigaction sa;1142 int ii;1143 1144 memset(&sa, 0, sizeof(sa));1145 sa.sa_handler = fatalsig;1146 for(ii = 0; ii < ALEN(sigs); ii++)1147 sigaction(sigs[ii], &sa, NULL);1148 }1149 1150 static void1151 fatalsig(int sig) {1152 struct sigaction sa;1153 1154 if(SIGCOUNT_MAX <= ++global_sigcount) {1155 memset(&sa, 0, sizeof(sa));1156 sa.sa_handler = SIG_DFL;1157 sigaction(sig, &sa, NULL);1158 raise(sig);1159 }1160 }
Note: See TracChangeset
for help on using the changeset viewer.