Changeset c9e72d1 for owl.c


Ignore:
Timestamp:
Nov 22, 2003, 11:33:00 AM (20 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, 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...]
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.