From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#9010: sigprocmask -> pthread_sigmask for Emacs Date: Wed, 06 Jul 2011 11:11:08 -0700 Organization: UCLA Computer Science Department Message-ID: <4E14A53C.4060709@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1309981137 23872 80.91.229.12 (6 Jul 2011 19:38:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Jul 2011 19:38:57 +0000 (UTC) To: 9010@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 06 21:38:52 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QeXvv-0000l5-4T for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jul 2011 21:38:51 +0200 Original-Received: from localhost ([::1]:50289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeXvu-0004Jw-3u for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jul 2011 15:38:50 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWZx-0005Si-G6 for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 14:12:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QeWZu-0002pE-Kj for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 14:12:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33736) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWZu-0002p2-6W for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 14:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QeWZt-00084y-Ub; Wed, 06 Jul 2011 14:12:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Jul 2011 18:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9010 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.130997589631011 (code B ref -1); Wed, 06 Jul 2011 18:12:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Jul 2011 18:11:36 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QeWZS-000848-O5 for submit@debbugs.gnu.org; Wed, 06 Jul 2011 14:11:35 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QeWZP-00083v-2U for submit@debbugs.gnu.org; Wed, 06 Jul 2011 14:11:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QeWZE-0002Xo-OW for submit@debbugs.gnu.org; Wed, 06 Jul 2011 14:11:25 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:41213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWZE-0002Xk-Fw for submit@debbugs.gnu.org; Wed, 06 Jul 2011 14:11:20 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWZB-0005Gv-4b for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 14:11:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QeWZ7-0002Wu-3x for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 14:11:16 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:51736) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWZ6-0002Wb-5J; Wed, 06 Jul 2011 14:11:12 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 9A22439E80FA; Wed, 6 Jul 2011 11:11:10 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TWuCnKDEDX8K; Wed, 6 Jul 2011 11:11:08 -0700 (PDT) Original-Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A42C139E80F8; Wed, 6 Jul 2011 11:11:08 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 06 Jul 2011 14:12:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:48110 Archived-At: Currently Emacs uses sigprocmask to alter signal masks, but sigprocmask is portable only for single-threaded applications, and Emacs can be multithreaded when it uses GTK (and is likely to become more multithreaded in the future). I've seen bug reports about this for other apps, in which misuse of sigprocmask (where pthread_sigmask should be used) causes segfaults and the like. I haven't reproduced the problem with GNU Emacs but any such bugs would quite possibly be random crashes that don't seem to be related to sigprocmask. To address this issue I plan to install the following patches, after some more testing. The first patch is the gnulib part (almost all automatically-generated); the second patch is the patch to Emacs proper. The gnulib part now generates a substitute file lib/signal.h for older hosts that don't have pthread_sigprocmask. For the Windows port, I expect the simplest fix would be to add a pthread_sigmask function that turns around and calls sigprocmask, but maybe Windows has pthread_sigmask already? And I don't expect the Windows port will need to worry about the signal.h wrapper. Add gnulib support for pthread_sigmask. * Makefile.in (GNULIB_MODULES): Add pthread_sigmask. (GNULIB_TOOL_FLAGS): Avoid sigprocmask. Emacs does its own implementation of 'sigprocmask' on Windows, and it assumes 'sigprocmask' on non-Windows hosts, so it doesn't need the sigprocmask module. * lib/signal.in.h, m4/pthread_sigmask.m4, m4/signal_h.m4: New files, automatically imported from gnulib. * lib/gnulib.mk, m4/gl-comp.m4: Automatically-imported update due to the above changes. * .bzrignore: Add lib/signal.h. === modified file '.bzrignore' --- .bzrignore 2011-06-27 04:31:43 +0000 +++ .bzrignore 2011-07-06 17:54:08 +0000 @@ -61,6 +61,7 @@ lib/unistd.h lib/warn-on-use.h lib/getopt.in-h +lib/signal.h lib/stdbool.in-h lib/stddef.in-h lib/stdint.in-h === modified file 'Makefile.in' --- Makefile.in 2011-06-25 08:40:38 +0000 +++ Makefile.in 2011-07-06 17:11:34 +0000 @@ -335,9 +335,11 @@ alloca-opt \ careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \ dup2 \ - filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink \ + filemode getloadavg getopt-gnu ignore-value intprops lstat \ + mktime pthread_sigmask readlink \ socklen stdarg stdio strftime strtoumax symlink sys_stat GNULIB_TOOL_FLAGS = \ + --avoid=sigprocmask \ --conditional-dependencies --import --no-changelog --no-vc-files \ --makefile-name=gnulib.mk sync-from-gnulib: $(gnulib_srcdir) === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-06-25 08:40:38 +0000 +++ lib/gnulib.mk 2011-07-06 17:15:18 +0000 @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --avoid=sigprocmask --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoumax symlink sys_stat MOSTLYCLEANFILES += core *.stackdump @@ -303,6 +303,44 @@ ## end gnulib module readlink +## begin gnulib module signal + +BUILT_SOURCES += signal.h + +# We need the following in order to create when the system +# doesn't have a complete one. +signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ + -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \ + -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \ + -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ + -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ + -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ + -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ + -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ + -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ + -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ + -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ + -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ + -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ + < $(srcdir)/signal.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += signal.h signal.h-t + +EXTRA_DIST += signal.in.h + +## end gnulib module signal + ## begin gnulib module stat if gl_GNULIB_ENABLED_stat === added file 'lib/signal.in.h' --- lib/signal.in.h 1970-01-01 00:00:00 +0000 +++ lib/signal.in.h 2011-07-06 17:15:12 +0000 @@ -0,0 +1,392 @@ +/* A GNU-like . + + Copyright (C) 2006-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_sig_atomic_t || defined __need_sigset_t +/* Special invocation convention inside glibc header files. */ + +# @INCLUDE_NEXT@ @NEXT_SIGNAL_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _@GUARD_PREFIX@_SIGNAL_H + +/* Define pid_t, uid_t. + Also, mingw defines sigset_t not in , but in . + On Solaris 10, includes , which eventually includes + us; so include now, before the second inclusion guard. */ +#include + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_SIGNAL_H@ + +#ifndef _@GUARD_PREFIX@_SIGNAL_H +#define _@GUARD_PREFIX@_SIGNAL_H + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +/* On AIX, sig_atomic_t already includes volatile. C99 requires that + 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. + Hence, redefine this to a non-volatile type as needed. */ +#if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +# if !GNULIB_defined_sig_atomic_t +typedef int rpl_sig_atomic_t; +# undef sig_atomic_t +# define sig_atomic_t rpl_sig_atomic_t +# define GNULIB_defined_sig_atomic_t 1 +# endif +#endif + +/* A set or mask of signals. */ +#if !@HAVE_SIGSET_T@ +# if !GNULIB_defined_sigset_t +typedef unsigned int sigset_t; +# define GNULIB_defined_sigset_t 1 +# endif +#endif + +/* Define sighandler_t, the type of signal handlers. A GNU extension. */ +#if !@HAVE_SIGHANDLER_T@ +# ifdef __cplusplus +extern "C" { +# endif +# if !GNULIB_defined_sighandler_t +typedef void (*sighandler_t) (int); +# define GNULIB_defined_sighandler_t 1 +# endif +# ifdef __cplusplus +} +# endif +#endif + + +#if @GNULIB_SIGNAL_H_SIGPIPE@ +# ifndef SIGPIPE +/* Define SIGPIPE to a value that does not overlap with other signals. */ +# define SIGPIPE 13 +# define GNULIB_defined_SIGPIPE 1 +/* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask', + 'write', 'stdio'. */ +# endif +#endif + + +/* Maximum signal number + 1. */ +#ifndef NSIG +# if defined __TANDEM +# define NSIG 32 +# endif +#endif + + +#if @GNULIB_PTHREAD_SIGMASK@ +# if @REPLACE_PTHREAD_SIGMASK@ +# undef pthread_sigmask +# define pthread_sigmask sigprocmask +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_sigmask +# if HAVE_RAW_DECL_PTHREAD_SIGMASK +_GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " + "use gnulib module pthread_sigmask for portability"); +# endif +#endif + + +#if @GNULIB_SIGPROCMASK@ +# if !@HAVE_POSIX_SIGNALBLOCKING@ + +/* Maximum signal number + 1. */ +# ifndef NSIG +# define NSIG 32 +# endif + +/* This code supports only 32 signals. */ +# if !GNULIB_defined_verify_NSIG_constraint +typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; +# define GNULIB_defined_verify_NSIG_constraint 1 +# endif + +# endif + +/* Test whether a given signal is contained in a signal set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on MacOS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigismember +# endif +# else +_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig)); +_GL_CXXALIASWARN (sigismember); + +/* Initialize a signal set to the empty set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on MacOS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigemptyset +# endif +# else +_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set)); +_GL_CXXALIASWARN (sigemptyset); + +/* Add a signal to a signal set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on MacOS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigaddset +# endif +# else +_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig)); +_GL_CXXALIASWARN (sigaddset); + +/* Remove a signal from a signal set. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on MacOS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigdelset +# endif +# else +_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig)); +_GL_CXXALIASWARN (sigdelset); + +/* Fill a signal set with all possible signals. */ +# if @HAVE_POSIX_SIGNALBLOCKING@ +/* This function is defined as a macro on MacOS X. */ +# if defined __cplusplus && defined GNULIB_NAMESPACE +# undef sigfillset +# endif +# else +_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set)); +_GL_CXXALIASWARN (sigfillset); + +/* Return the set of those blocked signals that are pending. */ +# if !@HAVE_POSIX_SIGNALBLOCKING@ +_GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set)); +_GL_CXXALIASWARN (sigpending); + +/* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. + Then, if SET is not NULL, affect the current set of blocked signals by + combining it with *SET as indicated in OPERATION. + In this implementation, you are not allowed to change a signal handler + while the signal is blocked. */ +# if !@HAVE_POSIX_SIGNALBLOCKING@ +# define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ +# define SIG_SETMASK 1 /* blocked_set = *set; */ +# define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ +_GL_FUNCDECL_SYS (sigprocmask, int, + (int operation, const sigset_t *set, sigset_t *old_set)); +# endif +_GL_CXXALIAS_SYS (sigprocmask, int, + (int operation, const sigset_t *set, sigset_t *old_set)); +_GL_CXXALIASWARN (sigprocmask); + +/* Install the handler FUNC for signal SIG, and return the previous + handler. */ +# ifdef __cplusplus +extern "C" { +# endif +# if !GNULIB_defined_function_taking_int_returning_void_t +typedef void (*_gl_function_taking_int_returning_void_t) (int); +# define GNULIB_defined_function_taking_int_returning_void_t 1 +# endif +# ifdef __cplusplus +} +# endif +# if !@HAVE_POSIX_SIGNALBLOCKING@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define signal rpl_signal +# endif +_GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +_GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +# else +_GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t, + (int sig, _gl_function_taking_int_returning_void_t func)); +# endif +_GL_CXXALIASWARN (signal); + +/* Raise signal SIG. */ +# if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef raise +# define raise rpl_raise +# endif +_GL_FUNCDECL_RPL (raise, int, (int sig)); +_GL_CXXALIAS_RPL (raise, int, (int sig)); +# else +_GL_CXXALIAS_SYS (raise, int, (int sig)); +# endif +_GL_CXXALIASWARN (raise); + +#elif defined GNULIB_POSIXCHECK +# undef sigaddset +# if HAVE_RAW_DECL_SIGADDSET +_GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigdelset +# if HAVE_RAW_DECL_SIGDELSET +_GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigemptyset +# if HAVE_RAW_DECL_SIGEMPTYSET +_GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigfillset +# if HAVE_RAW_DECL_SIGFILLSET +_GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigismember +# if HAVE_RAW_DECL_SIGISMEMBER +_GL_WARN_ON_USE (sigismember, "sigismember is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigpending +# if HAVE_RAW_DECL_SIGPENDING +_GL_WARN_ON_USE (sigpending, "sigpending is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +# undef sigprocmask +# if HAVE_RAW_DECL_SIGPROCMASK +_GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - " + "use the gnulib module sigprocmask for portability"); +# endif +#endif /* @GNULIB_SIGPROCMASK@ */ + + +#if @GNULIB_SIGACTION@ +# if !@HAVE_SIGACTION@ + +# if !@HAVE_SIGINFO_T@ + +# if !GNULIB_defined_siginfo_types + +/* Present to allow compilation, but unsupported by gnulib. */ +union sigval +{ + int sival_int; + void *sival_ptr; +}; + +/* Present to allow compilation, but unsupported by gnulib. */ +struct siginfo_t +{ + int si_signo; + int si_code; + int si_errno; + pid_t si_pid; + uid_t si_uid; + void *si_addr; + int si_status; + long si_band; + union sigval si_value; +}; +typedef struct siginfo_t siginfo_t; + +# define GNULIB_defined_siginfo_types 1 +# endif + +# endif /* !@HAVE_SIGINFO_T@ */ + +/* We assume that platforms which lack the sigaction() function also lack + the 'struct sigaction' type, and vice versa. */ + +# if !GNULIB_defined_struct_sigaction + +struct sigaction +{ + union + { + void (*_sa_handler) (int); + /* Present to allow compilation, but unsupported by gnulib. POSIX + says that implementations may, but not must, make sa_sigaction + overlap with sa_handler, but we know of no implementation where + they do not overlap. */ + void (*_sa_sigaction) (int, siginfo_t *, void *); + } _sa_func; + sigset_t sa_mask; + /* Not all POSIX flags are supported. */ + int sa_flags; +}; +# define sa_handler _sa_func._sa_handler +# define sa_sigaction _sa_func._sa_sigaction +/* Unsupported flags are not present. */ +# define SA_RESETHAND 1 +# define SA_NODEFER 2 +# define SA_RESTART 4 + +# define GNULIB_defined_struct_sigaction 1 +# endif + +_GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict, + struct sigaction *restrict)); + +# elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ + +# define sa_sigaction sa_handler + +# endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */ + +_GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict, + struct sigaction *restrict)); +_GL_CXXALIASWARN (sigaction); + +#elif defined GNULIB_POSIXCHECK +# undef sigaction +# if HAVE_RAW_DECL_SIGACTION +_GL_WARN_ON_USE (sigaction, "sigaction is unportable - " + "use the gnulib module sigaction for portability"); +# endif +#endif + +/* Some systems don't have SA_NODEFER. */ +#ifndef SA_NODEFER +# define SA_NODEFER 0 +#endif + + +#endif /* _@GUARD_PREFIX@_SIGNAL_H */ +#endif /* _@GUARD_PREFIX@_SIGNAL_H */ +#endif === modified file 'm4/gl-comp.m4' --- m4/gl-comp.m4 2011-06-25 08:40:38 +0000 +++ m4/gl-comp.m4 2011-07-06 17:25:15 +0000 @@ -52,7 +52,9 @@ # Code from module lstat: # Code from module mktime: # Code from module multiarch: + # Code from module pthread_sigmask: # Code from module readlink: + # Code from module signal: # Code from module socklen: # Code from module ssize_t: # Code from module stat: @@ -140,12 +142,15 @@ fi gl_TIME_MODULE_INDICATOR([mktime]) gl_MULTIARCH +gl_PTHREAD_SIGMASK +gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) gl_FUNC_READLINK if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then AC_LIBOBJ([readlink]) gl_PREREQ_READLINK fi gl_UNISTD_MODULE_INDICATOR([readlink]) +gl_SIGNAL_H gl_TYPE_SOCKLEN_T gt_TYPE_SSIZE_T gl_STDARG_H @@ -241,6 +246,9 @@ if test $REPLACE_LSTAT = 1; then func_gl_gnulib_m4code_stat fi + if test $REPLACE_PTHREAD_SIGMASK = 1; then + func_gl_gnulib_m4code_sigprocmask + fi if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then func_gl_gnulib_m4code_stat fi @@ -433,6 +441,7 @@ lib/sha256.h lib/sha512.c lib/sha512.h + lib/signal.in.h lib/stat.c lib/stdarg.in.h lib/stdbool.in.h @@ -470,10 +479,12 @@ m4/md5.m4 m4/mktime.m4 m4/multiarch.m4 + m4/pthread_sigmask.m4 m4/readlink.m4 m4/sha1.m4 m4/sha256.m4 m4/sha512.m4 + m4/signal_h.m4 m4/socklen.m4 m4/ssize_t.m4 m4/st_dm_mode.m4 === added file 'm4/pthread_sigmask.m4' --- m4/pthread_sigmask.m4 1970-01-01 00:00:00 +0000 +++ m4/pthread_sigmask.m4 2011-07-06 17:25:30 +0000 @@ -0,0 +1,26 @@ +# pthread_sigmask.m4 serial 2 +dnl Copyright (C) 2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_PTHREAD_SIGMASK], +[ + m4_ifdef([gl_THREADLIB], [ + AC_REQUIRE([gl_THREADLIB]) + if test "$gl_threads_api" = posix; then + gl_save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + AC_CHECK_FUNCS([pthread_sigmask]) + LIBS="$gl_save_LIBS" + else + ac_cv_func_pthread_sigmask=no + fi + ], [ + AC_CHECK_FUNCS_ONCE([pthread_sigmask]) + ]) + + if test $ac_cv_func_pthread_sigmask = no; then + REPLACE_PTHREAD_SIGMASK=1 + fi +]) === added file 'm4/signal_h.m4' --- m4/signal_h.m4 1970-01-01 00:00:00 +0000 +++ m4/signal_h.m4 2011-07-06 17:15:13 +0000 @@ -0,0 +1,76 @@ +# signal_h.m4 serial 14 +dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_SIGNAL_H], +[ + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T]) + gl_NEXT_HEADERS([signal.h]) + +# AIX declares sig_atomic_t to already include volatile, and C89 compilers +# then choke on 'volatile sig_atomic_t'. C99 requires that it compile. + AC_CHECK_TYPE([volatile sig_atomic_t], [], + [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[ +#include + ]]) + + AC_REQUIRE([AC_TYPE_UID_T]) + + dnl Persuade glibc to define sighandler_t. + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_TYPE([sighandler_t], [], [HAVE_SIGHANDLER_T=0], [[ +#include + ]]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include + ]], [pthread_sigmask sigaction + sigaddset sigdelset sigemptyset sigfillset sigismember + sigpending sigprocmask]) +]) + +AC_DEFUN([gl_CHECK_TYPE_SIGSET_T], +[ + AC_CHECK_TYPES([sigset_t], + [gl_cv_type_sigset_t=yes], [gl_cv_type_sigset_t=no], + [[ + #include + /* Mingw defines sigset_t not in , but in . */ + #include + ]]) + if test $gl_cv_type_sigset_t != yes; then + HAVE_SIGSET_T=0 + fi +]) + +AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_SIGNAL_H_DEFAULTS], +[ + GNULIB_PTHREAD_SIGMASK=0; AC_SUBST([GNULIB_PTHREAD_SIGMASK]) + GNULIB_SIGNAL_H_SIGPIPE=0; AC_SUBST([GNULIB_SIGNAL_H_SIGPIPE]) + GNULIB_SIGPROCMASK=0; AC_SUBST([GNULIB_SIGPROCMASK]) + GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) + HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T]) + HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T]) + HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION]) + HAVE_STRUCT_SIGACTION_SA_SIGACTION=1; + AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION]) + HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1; + AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T]) + HAVE_SIGHANDLER_T=1; AC_SUBST([HAVE_SIGHANDLER_T]) + REPLACE_PTHREAD_SIGMASK=0; AC_SUBST([REPLACE_PTHREAD_SIGMASK]) +]) ================================================================================ Use pthread_sigmask, not sigprocmask. * callproc.c (Fcall_process): * sysdep.c (sys_sigblock, sys_sigunblock, sys_sigsetmask): * process.c (create_process): sigprocmask is portable only for single-threaded applications, and Emacs can be multi-threaded when it uses GTK. === modified file 'src/callproc.c' --- src/callproc.c 2011-06-21 01:06:45 +0000 +++ src/callproc.c 2011-07-06 17:11:43 +0000 @@ -596,7 +596,7 @@ sigemptyset (&blocked); sigaddset (&blocked, SIGPIPE); sigaction (SIGPIPE, 0, &sigpipe_action); - sigprocmask (SIG_BLOCK, &blocked, &procmask); + pthread_sigmask (SIG_BLOCK, &blocked, &procmask); #endif BLOCK_INPUT; @@ -633,7 +633,7 @@ in the child. */ //signal (SIGPIPE, SIG_DFL); #ifdef HAVE_WORKING_VFORK - sigprocmask (SIG_SETMASK, &procmask, 0); + pthread_sigmask (SIG_SETMASK, &procmask, 0); #endif child_setup (filefd, fd1, fd_error, (char **) new_argv, @@ -645,7 +645,7 @@ #ifdef HAVE_WORKING_VFORK /* Restore the signal state. */ sigaction (SIGPIPE, &sigpipe_action, 0); - sigprocmask (SIG_SETMASK, &procmask, 0); + pthread_sigmask (SIG_SETMASK, &procmask, 0); #endif #endif /* not WINDOWSNT */ === modified file 'src/process.c' --- src/process.c 2011-07-01 09:18:46 +0000 +++ src/process.c 2011-07-06 17:11:43 +0000 @@ -1652,7 +1652,7 @@ sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action ); #endif #endif /* HAVE_WORKING_VFORK */ - sigprocmask (SIG_BLOCK, &blocked, &procmask); + pthread_sigmask (SIG_BLOCK, &blocked, &procmask); FD_SET (inchannel, &input_wait_mask); FD_SET (inchannel, &non_keyboard_wait_mask); @@ -1808,7 +1808,7 @@ signal (SIGPIPE, SIG_DFL); /* Stop blocking signals in the child. */ - sigprocmask (SIG_SETMASK, &procmask, 0); + pthread_sigmask (SIG_SETMASK, &procmask, 0); if (pty_flag) child_setup_tty (xforkout); @@ -1900,7 +1900,7 @@ #endif #endif /* HAVE_WORKING_VFORK */ /* Stop blocking signals in the parent. */ - sigprocmask (SIG_SETMASK, &procmask, 0); + pthread_sigmask (SIG_SETMASK, &procmask, 0); /* Now generate the error if vfork failed. */ if (pid < 0) === modified file 'src/sysdep.c' --- src/sysdep.c 2011-07-05 02:51:15 +0000 +++ src/sysdep.c 2011-07-06 17:11:43 +0000 @@ -1534,7 +1534,7 @@ sys_sigblock (sigset_t new_mask) { sigset_t old_mask; - sigprocmask (SIG_BLOCK, &new_mask, &old_mask); + pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); return (old_mask); } @@ -1542,7 +1542,7 @@ sys_sigunblock (sigset_t new_mask) { sigset_t old_mask; - sigprocmask (SIG_UNBLOCK, &new_mask, &old_mask); + pthread_sigmask (SIG_UNBLOCK, &new_mask, &old_mask); return (old_mask); } @@ -1550,7 +1550,7 @@ sys_sigsetmask (sigset_t new_mask) { sigset_t old_mask; - sigprocmask (SIG_SETMASK, &new_mask, &old_mask); + pthread_sigmask (SIG_SETMASK, &new_mask, &old_mask); return (old_mask); }