Changeset c9e72d1


Ignore:
Timestamp:
Nov 22, 2003, 11:33:00 AM (17 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
1e34e40
Parents:
f1645da
Message:
	Catch SIGPIPE and print an error rather than crashing.
	        [It's possible that this may have some portability
		issues under Solaris and we may need to add some
		configure stuff around SA_SIGINFO...]
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rf1645da rc9e72d1  
    11$Id$
    22
    3 2.0.13-pre-1
     32.0.13-pre-2
    44        Changed startup message for new mailing list
    55        blist now prints AIM info even if .anyone is unreadable
     6        Catch SIGPIPE and print an error rather than crashing.
     7                [It's possible that this may have some portability
     8                issues under Solaris and we may need to add some
     9                configure stuff around SA_SIGINFO...]
    610       
    7112.0.12
  • global.c

    r5a9f6fe rc9e72d1  
    105105
    106106  owl_errqueue_init(&(g->errqueue));
     107
     108  g->got_err_signal=0;
    107109}
    108110
     
    844846  return(&(g->errqueue));
    845847}
     848
     849void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
     850{
     851  g->got_err_signal = signum;
     852  if (siginfo) {
     853    g->err_signal_info = *siginfo;
     854  } else {
     855    memset(&(g->err_signal_info), 0, sizeof(siginfo_t));
     856  }
     857}
     858
     859int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
     860{
     861  int signum;
     862  if (siginfo && g->got_err_signal) {
     863    *siginfo = g->err_signal_info;
     864  }
     865  signum = g->got_err_signal;
     866  g->got_err_signal = 0;
     867  return signum;
     868}
     869
  • owl.c

    ra0a5179 rc9e72d1  
    118118  /* signal handler */
    119119  owl_function_debugmsg("startup: setting up signal handler");
    120   sigact.sa_handler=sig_handler;
     120  /*sigact.sa_handler=sig_handler;*/
     121  sigact.sa_sigaction=sig_handler;
    121122  sigemptyset(&sigact.sa_mask);
    122   sigact.sa_flags=0;
     123  sigact.sa_flags=SA_SIGINFO;
    123124  sigaction(SIGWINCH, &sigact, NULL);
    124125  sigaction(SIGALRM, &sigact, NULL);
     126  sigaction(SIGPIPE, &sigact, NULL);
    125127
    126128  /* screen init */
     
    589591#endif   
    590592
     593    /* Log any error signals */
     594    {
     595      siginfo_t si;
     596      int signum;
     597      if ((signum = owl_global_get_errsignal_and_clear(&g, &si)) > 0) {
     598        owl_function_error("Got unexpected signal: %d %s  (code: %d  fd: %d  band: %d  errno: %d)",
     599                           signum, signum==SIGPIPE?"SIGPIPE":"",
     600                           si.si_code, si.si_fd, si.si_band, si.si_errno);
     601      }
     602    }
     603
    591604  }
    592605}
    593606
    594 void sig_handler(int sig) {
     607void sig_handler(int sig, siginfo_t *si, void *data) {
    595608  if (sig==SIGWINCH) {
    596609    /* we can't inturrupt a malloc here, so it just sets a flag
     
    598611     */
    599612    owl_function_resize();
    600   }
     613  } else if (sig==SIGPIPE) {
     614    /* Set a flag and some info that we got the sigpipe
     615     * so we can record that we got it and why... */
     616    owl_global_set_errsignal(&g, sig, si);
     617  }
     618
    601619}
    602620
  • owl.h

    r52f3507 rc9e72d1  
    88#include <regex.h>
    99#include <time.h>
     10#include <signal.h>
    1011#include <libfaim/aim.h>
    1112#include "config.h"
     
    1920static const char owl_h_fileIdent[] = "$Id$";
    2021
    21 #define OWL_VERSION         2.0.13-pre-1
    22 #define OWL_VERSION_STRING "2.0.13-pre-1"
     22#define OWL_VERSION         2.0.13-pre-2
     23#define OWL_VERSION_STRING "2.0.13-pre-2"
    2324
    2425/* Feature that is being tested to redirect stderr through a pipe.
     
    486487  int havezephyr;
    487488  int haveaim;
     489  int got_err_signal;       /* 1 if we got an unexpected signal */
     490  siginfo_t err_signal_info;
    488491} owl_global;
    489492
Note: See TracChangeset for help on using the changeset viewer.