Changeset 3535a6e for select.c


Ignore:
Timestamp:
May 23, 2011, 8:57:46 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, 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
  • select.c

    r2c79eae r3535a6e  
    331331    owl_function_makemsg("Unable to handle keypress");
    332332  }
    333 }
    334 
    335 void owl_select_mask_signals(sigset_t *oldmask) {
    336   sigset_t set;
    337 
    338   sigemptyset(&set);
    339   sigaddset(&set, SIGWINCH);
    340   sigaddset(&set, SIGALRM);
    341   sigaddset(&set, SIGPIPE);
    342   sigaddset(&set, SIGTERM);
    343   sigaddset(&set, SIGHUP);
    344   sigaddset(&set, SIGINT);
    345   sigprocmask(SIG_BLOCK, &set, oldmask);
    346 }
    347 
    348 void owl_select_handle_intr(sigset_t *restore)
    349 {
    350   owl_input in;
    351 
    352   owl_global_unset_interrupted(&g);
    353 
    354   sigprocmask(SIG_SETMASK, restore, NULL);
    355 
    356   in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR];
    357   owl_process_input_char(in);
    358333}
    359334
Note: See TracChangeset for help on using the changeset viewer.