Changeset 3535a6e for global.c


Ignore:
Timestamp:
May 23, 2011, 8:57:46 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
257b9c4
Parents:
959cb85
git-author:
David Benjamin <davidben@mit.edu> (02/26/11 00:15:35)
git-committer:
David Benjamin <davidben@mit.edu> (05/23/11 20:57:46)
Message:
First go at sigwait-based signal handling

Instead of relying on pselect and signal masking to listen for signals,
which glib doesn't support, we spawn a dedicated signal thread that
loops in sigwait. These signals are posted back to the main message loop
which may handle them at will. This avoids the need for complex
reentrant code and sig_atomic_t.

This removes the final pre-select action.

SIGINT doesn't quite work right yet because we can no longer take it in
the middle of an event loop iteration.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r2c79eae r3535a6e  
    1616
    1717  g_type_init();
     18  g_thread_init(NULL);
    1819
    1920  owl_select_init();
     
    101102
    102103  owl_errqueue_init(&(g->errqueue));
    103   g->got_err_signal=0;
    104104
    105105  owl_zbuddylist_create(&(g->zbuddies));
     
    112112  owl_list_create(&(g->psa_list));
    113113  g->timerlist = NULL;
    114   g->interrupted = FALSE;
    115114  g->kill_buffer = NULL;
    116115}
     
    350349
    351350void owl_global_set_resize_pending(owl_global *g) {
    352   g->resizepending=1;
     351  g->resizepending = true;
    353352}
    354353
     
    450449  /* resize the screen.  If lines or cols is 0 use the terminal size */
    451450  if (!g->resizepending) return;
    452   g->resizepending = 0;
     451  g->resizepending = false;
    453452
    454453  owl_global_get_terminal_size(&g->lines, &g->cols);
     
    826825}
    827826
    828 void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
    829 {
    830   g->got_err_signal = signum;
    831   if (siginfo) {
    832     g->err_signal_info = *siginfo;
    833   } else {
    834     siginfo_t si;
    835     memset(&si, 0, sizeof(si));
    836     g->err_signal_info = si;
    837   }
    838 }
    839 
    840 int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
    841 {
    842   int signum;
    843   if (siginfo && g->got_err_signal) {
    844     *siginfo = g->err_signal_info;
    845   }
    846   signum = g->got_err_signal;
    847   g->got_err_signal = 0;
    848   return signum;
    849 }
    850 
    851 
    852827owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
    853828{
     
    888863{
    889864  return &(g->timerlist);
    890 }
    891 
    892 int owl_global_is_interrupted(const owl_global *g) {
    893   return g->interrupted;
    894 }
    895 
    896 void owl_global_set_interrupted(owl_global *g) {
    897   g->interrupted = 1;
    898 }
    899 
    900 void owl_global_unset_interrupted(owl_global *g) {
    901   g->interrupted = 0;
    902865}
    903866
Note: See TracChangeset for help on using the changeset viewer.