Changeset 7892963


Ignore:
Timestamp:
Apr 27, 2010, 5:21:31 PM (10 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
8479494
Parents:
72634c5
git-author:
Anders Kaseorg <andersk@mit.edu> (04/27/10 16:31:56)
git-committer:
Anders Kaseorg <andersk@mit.edu> (04/27/10 17:21:31)
Message:
Mark variables modified from signal handlers as volatile sig_atomic_t.

According to POSIX, this is the only type of variable (other than
errno) that may be accessed from a signal handler with defined
results.  In practice, at least the volatile is important to prevent
the compiler from reordering accesses.

err_signal_info is a bigger struct that cannot be assigned atomically,
but it’s only for debugging so we just do the best we can.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Nelson Elhage <nelhage@mit.edu>
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r98d296d r7892963  
    937937    g->err_signal_info = *siginfo;
    938938  } else {
    939     memset(&(g->err_signal_info), 0, sizeof(siginfo_t));
     939    siginfo_t si;
     940    memset(&si, 0, sizeof(si));
     941    g->err_signal_info = si;
    940942  }
    941943}
  • owl.h

    r1cfcab7 r7892963  
    568568  int needrefresh;
    569569  int rightshift;
    570   int resizepending;
     570  volatile sig_atomic_t resizepending;
    571571  int recwinlines;
    572572  char *thishost;
     
    610610  int haveaim;
    611611  int ignoreaimlogin;
    612   int got_err_signal;      /* 1 if we got an unexpected signal */
    613   siginfo_t err_signal_info;
     612  volatile sig_atomic_t got_err_signal; /* 1 if we got an unexpected signal */
     613  volatile siginfo_t err_signal_info;
    614614  owl_zbuddylist zbuddies;
    615615  owl_timer zephyr_buddycheck_timer;
     
    623623  owl_timer *aim_nop_timer;
    624624  int load_initial_subs;
    625   int interrupted;
     625  volatile sig_atomic_t interrupted;
    626626} owl_global;
    627627
Note: See TracChangeset for help on using the changeset viewer.