Changeset 40bda84


Ignore:
Timestamp:
Oct 3, 2009, 10:11:30 AM (14 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:
340c3e7
Parents:
e2f7963
git-author:
Nelson Elhage <nelhage@mit.edu> (09/14/09 21:06:14)
git-committer:
Nelson Elhage <nelhage@mit.edu> (10/03/09 10:11:30)
Message:
Catch ^Z and display a message instead of suspending.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r8240bce r40bda84  
    115115  g->timerlist = NULL;
    116116  g->interrupted = FALSE;
     117  g->got_sigtstp = FALSE;
    117118}
    118119
     
    968969  g->interrupted = 0;
    969970}
     971
     972int owl_global_is_sigstp(const owl_global *g) {
     973  return g->got_sigtstp;
     974}
     975
     976void owl_global_set_got_sigstp(owl_global *g) {
     977  g->got_sigtstp = 1;
     978}
     979
     980void owl_global_unset_got_sigstp(owl_global *g) {
     981  g->got_sigtstp = 0;
     982}
  • owl.c

    rc79a047 r40bda84  
    378378}
    379379
     380void sigtstp_handler(int sig, siginfo_t *si, void *data)
     381{
     382  owl_global_set_got_sigstp(&g);
     383}
     384
    380385void owl_register_signal_handlers(void) {
    381386  struct sigaction sigact;
     
    395400  sigaction(SIGINT, &sigact, NULL);
    396401
     402  sigact.sa_sigaction=sigtstp_handler;
     403  sigaction(SIGTSTP, &sigact, NULL);
    397404}
    398405
  • owl.h

    r24ccc01 r40bda84  
    588588  int load_initial_subs;
    589589  int interrupted;
     590  int got_sigtstp;
    590591} owl_global;
    591592
  • select.c

    rc79a047 r40bda84  
    325325}
    326326
    327 void owl_select_handle_intr(void)
     327void owl_select_mask_signals(sigset_t *oldmask) {
     328  sigset_t set;
     329
     330  sigemptyset(&set);
     331  sigaddset(&set, SIGINT);
     332  sigaddset(&set, SIGTSTP);
     333  sigprocmask(SIG_BLOCK, &set, oldmask);
     334}
     335
     336void owl_select_handle_intr(sigset_t *restore)
    328337{
    329338  owl_input in;
    330339
    331340  owl_global_unset_interrupted(&g);
    332   owl_function_unmask_sigint(NULL);
     341
     342  sigprocmask(SIG_SETMASK, restore, NULL);
    333343
    334344  in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR];
    335345  owl_process_input_char(in);
     346}
     347
     348void owl_select_check_tstp() {
     349  if(owl_global_is_sigstp(&g)) {
     350    owl_function_makemsg("Use :suspend to suspend.");
     351    owl_global_unset_got_sigstp(&g);
     352  }
    336353}
    337354
     
    347364  owl_select_process_timers(&timeout);
    348365
    349   owl_function_mask_sigint(&mask);
     366  owl_select_mask_signals(&mask);
     367
     368  owl_select_check_tstp();
    350369  if(owl_global_is_interrupted(&g)) {
    351     owl_select_handle_intr();
     370    owl_select_handle_intr(&mask);
    352371    return;
    353372  }
     
    381400  /* END AIM HACK */
    382401
    383 
    384402  ret = pselect(max_fd+1, &r, &aim_wfds, &e, &timeout, &mask);
    385403
    386404  if(ret < 0 && errno == EINTR) {
     405    owl_select_check_tstp();
    387406    if(owl_global_is_interrupted(&g)) {
    388       owl_select_handle_intr();
    389     }
     407      owl_select_handle_intr(NULL);
     408    }
     409    sigprocmask(SIG_SETMASK, &mask, NULL);
    390410    return;
    391411  }
    392412
    393   owl_function_unmask_sigint(NULL);
     413  sigprocmask(SIG_SETMASK, &mask, NULL);
    394414
    395415  if(ret > 0) {
Note: See TracChangeset for help on using the changeset viewer.