Changeset adee9cc


Ignore:
Timestamp:
May 4, 2009, 9:55:11 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d6bd3f1
Parents:
790ab12
git-author:
Nelson Elhage <nelhage@mit.edu> (05/03/09 15:31:50)
git-committer:
Nelson Elhage <nelhage@mit.edu> (05/04/09 21:55:11)
Message:
Enable signals, and add an interrupted flag.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • global.c

    rf34dd65 radee9cc  
    116116  owl_list_create(&(g->dispatchlist));
    117117  g->timerlist = NULL;
     118  g->interrupted = FALSE;
    118119}
    119120
     
    934935  return &(g->timerlist);
    935936}
     937
     938/*
     939 * Note: This must be called with SIGINT masked in order to avoid
     940 * races. This will unset the interrupt flag and unblock SIGINT before
     941 * returning.
     942 */
     943int owl_global_is_interrupted(owl_global *g) {
     944  int interrupted;
     945  sigset_t intr;
     946  sigemptyset(&intr);
     947  sigaddset(&intr, SIGINT);
     948
     949  interrupted = g->interrupted;
     950  g->interrupted = 0;
     951
     952  sigprocmask(SIG_UNBLOCK, &intr, NULL);
     953  return interrupted;
     954}
     955
     956void owl_global_set_interrupted(owl_global *g) {
     957  g->interrupted = 1;
     958}
     959
     960void owl_global_unset_interrupted(owl_global *g) {
     961  g->interrupted = 0;
     962}
  • owl.c

    r5657d53 radee9cc  
    137137  sigaction(SIGHUP, &sigact, NULL);
    138138
     139  sigact.sa_sigaction=sigint_handler;
     140  sigaction(SIGINT, &sigact, NULL);
     141
    139142  /* save initial terminal settings */
    140143  tcgetattr(0, owl_global_get_startup_tio(&g));
     
    156159  use_default_colors();
    157160#endif
    158   raw();
     161  cbreak();
    159162  noecho();
    160163
     
    675678}
    676679
     680void sigint_handler(int sig, siginfo_t *si, void *data)
     681{
     682  owl_global_set_interrupted(&g);
     683}
     684
    677685void usage()
    678686{
  • owl.h

    r4a999a7 radee9cc  
    595595  owl_timer *aim_nop_timer;
    596596  int load_initial_subs;
     597  int interrupted;
    597598} owl_global;
    598599
  • select.c

    r1895c29 radee9cc  
    326326
    327327  if ( select(max_fd+1, &r, &aim_wfds, &e, &timeout) ) {
     328    owl_global_unset_interrupted(&g);
    328329    /* Merge fd_sets and clear AIM FDs. */
    329330    for(i = 0; i <= max_fd; i++) {
Note: See TracChangeset for help on using the changeset viewer.