Changeset 1d21d9f


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:
5f3f1e4
Parents:
ba12b44
git-author:
David Benjamin <davidben@mit.edu> (03/03/11 09:50:32)
git-committer:
David Benjamin <davidben@mit.edu> (05/23/11 20:57:46)
Message:
Use sigwaitinfo instead of sigwait

Eh, may as well give the signal handlers a little bit more rope.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    rba12b44 r1d21d9f  
    380380}
    381381
    382 static void sig_handler(int sig, void *data) {
     382static void sig_handler(const siginfo_t *siginfo, void *data) {
    383383  /* If it was an interrupt, set a flag so we can handle it earlier if
    384384   * needbe. sig_handler_main_thread will check the flag to make sure
    385385   * no one else took it. */
    386   if (sig == SIGINT) {
     386  if (siginfo->si_signo == SIGINT) {
    387387    owl_global_add_interrupt(&g);
    388388  }
    389389  /* Send a message to the main thread. */
    390   owl_select_post_task(sig_handler_main_thread, GINT_TO_POINTER(sig), NULL);
     390  owl_select_post_task(sig_handler_main_thread,
     391                       GINT_TO_POINTER(siginfo->si_signo), NULL);
    391392}
    392393
  • signal.c

    r08e9842 r1d21d9f  
    88static sigset_t signal_set;
    99
    10 static void (*signal_cb)(int, void*);
     10static void (*signal_cb)(const siginfo_t*, void*);
    1111static void *signal_cbdata;
    1212
     
    1919 * This function /must/ be called before any other threads are
    2020 * created. (Otherwise the signals will not get blocked correctly.) */
    21 void owl_signal_init(const sigset_t *set, void (*callback)(int, void*), void *data) {
     21void owl_signal_init(const sigset_t *set, void (*callback)(const siginfo_t*, void*), void *data) {
    2222  int ret;
    2323
     
    4141static void *signal_thread_func(void *data) {
    4242  while (1) {
    43      int signal;
     43    siginfo_t siginfo;
    4444    int ret;
    4545
    46     ret = sigwait(&signal_set, &signal);
    47     /* TODO: Print an error? man page claims it never errors. */
    48     if (ret != 0)
     46    ret = sigwaitinfo(&signal_set, &siginfo);
     47    /* TODO: Print an error? */
     48    if (ret < 0)
    4949      continue;
    5050
    51     signal_cb(signal, signal_cbdata);
     51    signal_cb(&siginfo, signal_cbdata);
    5252    /* Die on SIGTERM. */
    53     if (signal == SIGTERM)
     53    if (siginfo.si_signo == SIGTERM)
    5454      break;
    5555  }
Note: See TracChangeset for help on using the changeset viewer.