Changeset 37d188f
- Timestamp:
- Mar 25, 2011, 3:46:46 AM (14 years ago)
- Children:
- 0af5f9d
- Parents:
- 87833a8
- git-author:
- David Benjamin <davidben@mit.edu> (02/26/11 14:38:04)
- git-committer:
- David Benjamin <davidben@mit.edu> (03/25/11 03:46:46)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
rfafb842 r37d188f 2995 2995 i--; 2996 2996 } 2997 #if 0 2998 /* FIXME!!! */ 2999 owl_function_mask_sigint(NULL); 3000 if(owl_global_is_interrupted(&g)) { 3001 owl_global_unset_interrupted(&g); 3002 owl_function_unmask_sigint(NULL); 2997 if (owl_global_take_interrupt(&g)) { 3003 2998 owl_function_makemsg("Search interrupted!"); 3004 2999 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 3005 3000 return; 3006 3001 } 3007 owl_function_unmask_sigint(NULL);3008 #endif3009 3002 } 3010 3003 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 3089 3082 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3090 3083 3091 #if 0 3092 /* FIXME!! */ 3093 owl_function_mask_sigint(NULL); 3094 if(owl_global_is_interrupted(&g)) { 3084 if (owl_global_take_interrupt(&g)) { 3095 3085 interrupted = 1; 3096 owl_global_unset_interrupted(&g);3097 owl_function_unmask_sigint(NULL);3098 3086 owl_function_makemsg("Interrupted!"); 3099 3087 break; 3100 3088 } 3101 3102 owl_function_unmask_sigint(NULL);3103 #endif3104 3089 3105 3090 if (ret!=ZERR_NONE) { … … 3506 3491 } 3507 3492 3508 void owl_function_mask_sigint(sigset_t *oldmask) {3509 sigset_t intr;3510 3511 sigemptyset(&intr);3512 sigaddset(&intr, SIGINT);3513 sigprocmask(SIG_BLOCK, &intr, oldmask);3514 }3515 3516 void owl_function_unmask_sigint(sigset_t *oldmask) {3517 sigset_t intr;3518 3519 sigemptyset(&intr);3520 sigaddset(&intr, SIGINT);3521 sigprocmask(SIG_UNBLOCK, &intr, oldmask);3522 }3523 3524 3493 void _owl_function_mark_message(const owl_message *m) 3525 3494 { -
global.c
rfafb842 r37d188f 113 113 g->timerlist = NULL; 114 114 g->kill_buffer = NULL; 115 116 g->interrupt_count = 0; 117 g->interrupt_lock = g_mutex_new(); 115 118 } 116 119 … … 930 933 g->kill_buffer = g_strndup(kill, len); 931 934 } 935 936 void owl_global_add_interrupt(owl_global *g) { 937 /* TODO: This can almost certainly be done with atomic 938 * operations. Whatever. */ 939 g_mutex_lock(g->interrupt_lock); 940 g->interrupt_count++; 941 g_mutex_unlock(g->interrupt_lock); 942 } 943 944 bool owl_global_take_interrupt(owl_global *g) { 945 bool ans = false; 946 g_mutex_lock(g->interrupt_lock); 947 if (g->interrupt_count > 0) { 948 ans = true; 949 g->interrupt_count--; 950 } 951 g_mutex_unlock(g->interrupt_lock); 952 return ans; 953 } -
owl.c
r87833a8 r37d188f 369 369 } else if (sig == SIGTERM || sig == SIGHUP) { 370 370 owl_function_quit(); 371 } else if (sig == SIGINT ) {371 } else if (sig == SIGINT && owl_global_take_interrupt(&g)) { 372 372 owl_input in; 373 373 in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR]; … … 381 381 GSource *source; 382 382 383 /* TODO: Special-case SIGINT so that it can interrupt outside the 384 * event loop. */ 385 383 /* If it was an interrupt, set a flag so we can handle it earlier if 384 * needbe. sig_handler_main_thread will check the flag to make sure 385 * no one else took it. */ 386 if (sig == SIGINT) { 387 owl_global_add_interrupt(&g); 388 } 386 389 /* Send a message to the main thread. */ 387 390 source = g_idle_source_new(); -
owl.h
r96ade35 r37d188f 633 633 FILE *debug_file; 634 634 char *kill_buffer; 635 int interrupt_count; 636 GMutex *interrupt_lock; 635 637 } owl_global; 636 638
Note: See TracChangeset
for help on using the changeset viewer.