aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorPaul Eggert2012-09-06 18:27:44 -0700
committerPaul Eggert2012-09-06 18:27:44 -0700
commit2fe282993cf9c84f5be424dc93d03f9705a7edd8 (patch)
tree229edb6fe29e66984b2992f3f9fa081cd7fe8920 /src/gtkutil.c
parent845ce106c0ab157e25416964330875ad6c24b699 (diff)
downloademacs-2fe282993cf9c84f5be424dc93d03f9705a7edd8.tar.gz
emacs-2fe282993cf9c84f5be424dc93d03f9705a7edd8.zip
Signal-handler cleanup.
Emacs's signal handlers were written in the old 4.2BSD style with sigblock and sigmask and so forth, and this led to some inefficiencies and confusion. Rewrite these to use pthread_sigmask etc. without copying signal sets around. Also, get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and 'signal', and instead use functions that do not attempt to take over the system name space. This patch causes Emacs's text segment to shrink by 0.7% on my platform, Fedora 17 x86-64. * configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF): Adjust to syssignal.h changes. (SIGNAL_H_AB): Remove; no longer needed. * src/alloc.c, src/emacsgtkfixed.c, src/nsfns.m, src/widget.c, src/xmenu.c: Do not include <signal.h> or "syssignal.h", as these modules do not use signals. * src/atimer.c, src/callproc.c, src/data.c, src/dispnew.c, src/emacs.c: * src/floatfns.c, src/gtkutil.c, src/keyboard.c, src/process.c, src/sound.c: * src/sysdep.c, src/term.c, src/xterm.c: Do not include <signal.h>, as "syssignal.h" does that for us now. * src/atimer.c (sigmask_atimers): New function. (block_atimers, unblock_atimers): New functions, replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS. All uses replaced. * src/conf_post.h [SIGNAL_H_AHB]: Do not include <signal.h>; no longer needed here. * src/emacs.c (main): Inspect existing signal handler with sigaction, so that there's no need to block and unblock SIGHUP. * src/sysdep.c (struct save_signal): New member 'action', replacing old member 'handler'. (save_signal_handlers, restore_signal_handlers): Use sigaction instead of 'signal' to save and restore. (get_set_sighandler, set_sighandler) [!WINDOWSNT]: New function. All users of 'signal' modified to use set_sighandler if they're writeonly, and to use sys_signal if they're read+write. (emacs_sigaction_init, forwarded_signal): New functions. (sys_signal): Remove. All uses replaced by calls to sigaction and emacs_sigaction_init, or by direct calls to 'signal'. (sys_sigmask) [!__GNUC__]: Remove; no longer needed. (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove; all uses replaced by pthread_sigmask etc. calls. * src/syssignal.h: Include <signal.h>. (emacs_sigaction_init, forwarded_signal): New decls. (SIGMASKTYPE): Remove. All uses replaced by its definiens, sigset_t. (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask. (sigmask, sys_sigmask): Remove; no longer needed. (sigpause): Remove. All uses replaced by its definiens, sigsuspend. (sigblock, sigunblock, sigfree): (sigsetmask) [!defined sigsetmask]: Remove. All uses replaced by pthread_sigmask. (signal): Remove. Its remaining uses (with SIG_DFL and SIG_IGN) no longer need to be replaced, and its typical old uses are now done via emacs_sigaction_init and sigaction. (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls. (sys_sigdel): Remove; unused. (NSIG): Remove a FIXME; the code's fine. Remove an unnecessary ifdef. Fixes: debbugs:12327
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 3bce5be9cd0..884574e1062 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#ifdef USE_GTK 22#ifdef USE_GTK
23#include <float.h> 23#include <float.h>
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h> 25#include <setjmp.h>
27 26
@@ -1979,7 +1978,10 @@ xg_get_file_name (FRAME_PTR f,
1979 /* I really don't know why this is needed, but without this the GLIBC add on 1978 /* I really don't know why this is needed, but without this the GLIBC add on
1980 library linuxthreads hangs when the Gnome file chooser backend creates 1979 library linuxthreads hangs when the Gnome file chooser backend creates
1981 threads. */ 1980 threads. */
1982 sigblock (sigmask (__SIGRTMIN)); 1981 sigset_t blocked;
1982 sigemptyset (&blocked);
1983 sigaddset (&blocked, __SIGRTMIN);
1984 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1983#endif /* HAVE_PTHREAD */ 1985#endif /* HAVE_PTHREAD */
1984 1986
1985#ifdef HAVE_GTK_FILE_SELECTION_NEW 1987#ifdef HAVE_GTK_FILE_SELECTION_NEW
@@ -2001,7 +2003,7 @@ xg_get_file_name (FRAME_PTR f,
2001 filesel_done = xg_dialog_run (f, w); 2003 filesel_done = xg_dialog_run (f, w);
2002 2004
2003#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2005#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2004 sigunblock (sigmask (__SIGRTMIN)); 2006 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2005#endif 2007#endif
2006 2008
2007 if (filesel_done == GTK_RESPONSE_OK) 2009 if (filesel_done == GTK_RESPONSE_OK)
@@ -2057,7 +2059,10 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2057 Lisp_Object font = Qnil; 2059 Lisp_Object font = Qnil;
2058 2060
2059#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2061#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2060 sigblock (sigmask (__SIGRTMIN)); 2062 sigset_t blocked;
2063 sigemptyset (&blocked);
2064 sigaddset (&blocked, __SIGRTMIN);
2065 pthread_sigmask (SIG_BLOCK, &blocked, 0);
2061#endif /* HAVE_PTHREAD */ 2066#endif /* HAVE_PTHREAD */
2062 2067
2063 w = gtk_font_chooser_dialog_new 2068 w = gtk_font_chooser_dialog_new
@@ -2086,7 +2091,7 @@ xg_get_font (FRAME_PTR f, const char *default_name)
2086 done = xg_dialog_run (f, w); 2091 done = xg_dialog_run (f, w);
2087 2092
2088#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN) 2093#if defined (HAVE_PTHREAD) && defined (__SIGRTMIN)
2089 sigunblock (sigmask (__SIGRTMIN)); 2094 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2090#endif 2095#endif
2091 2096
2092 if (done == GTK_RESPONSE_OK) 2097 if (done == GTK_RESPONSE_OK)