diff options
author | Gary Kramlich <grim@reaperworld.com> | 2017-09-29 01:38:29 +0000 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2017-09-29 01:38:29 +0000 |
commit | 1c9507a202f8e3be3da75692426dd56c7fdc8330 (patch) | |
tree | d52452068b11461421d08f6e8132a9b3b19e5c2d | |
parent | 39a7d888c733371a4706141c4f2ad3805381ff03 (diff) | |
parent | 096f645f5276c84fdc2a628653667decb592f34b (diff) | |
download | pidgin-1c9507a202f8e3be3da75692426dd56c7fdc8330.tar.gz |
Merged in strangeways/main/trac-16680 (pull request #269)
Respect the original SIGWINCH's handler SA_SIGINFO field
Approved-by: Gary Kramlich <grim@reaperworld.com>
Approved-by: dx <dx@dxzone.com.ar>
-rw-r--r-- | finch/libgnt/gntmain.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/finch/libgnt/gntmain.c b/finch/libgnt/gntmain.c index 71548df9b5..bccf021c02 100644 --- a/finch/libgnt/gntmain.c +++ b/finch/libgnt/gntmain.c @@ -407,10 +407,11 @@ raise: #ifdef SIGWINCH static void (*org_winch_handler)(int); +static void (*org_winch_handler_sa)(int, siginfo_t *, void *); #endif static void -sighandler(int sig) +sighandler(int sig, siginfo_t *info, void *data) { switch (sig) { #ifdef SIGWINCH @@ -419,16 +420,15 @@ sighandler(int sig) g_idle_add((GSourceFunc)refresh_screen, NULL); if (org_winch_handler) org_winch_handler(sig); - signal(SIGWINCH, sighandler); + if (org_winch_handler_sa) + org_winch_handler_sa(sig, info, data); break; #endif case SIGCHLD: clean_pid(); - signal(SIGCHLD, sighandler); break; case SIGINT: ask_before_exit(); - signal(SIGINT, sighandler); break; } } @@ -456,6 +456,10 @@ void gnt_init() { char *filename; const char *locale; + struct sigaction act; +#ifdef SIGWINCH + struct sigaction oact; +#endif if (channel) return; @@ -501,11 +505,25 @@ void gnt_init() werase(stdscr); wrefresh(stdscr); + act.sa_sigaction = sighandler; + sigemptyset(&act.sa_mask); + act.sa_flags = SA_SIGINFO; + #ifdef SIGWINCH - org_winch_handler = signal(SIGWINCH, sighandler); + org_winch_handler = NULL; + org_winch_handler_sa = NULL; + sigaction(SIGWINCH, &act, &oact); + if (oact.sa_flags & SA_SIGINFO) + { + org_winch_handler_sa = oact.sa_sigaction; + } + else if (oact.sa_handler != SIG_DFL && oact.sa_handler != SIG_IGN) + { + org_winch_handler = oact.sa_handler; + } #endif - signal(SIGCHLD, sighandler); - signal(SIGINT, sighandler); + sigaction(SIGCHLD, &act, NULL); + sigaction(SIGINT, &act, NULL); signal(SIGPIPE, SIG_IGN); #if !GLIB_CHECK_VERSION(2, 36, 0) |