mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Merged with gpg 1.4.3 code.
The gpg part does not yet build.
This commit is contained in:
parent
751a3aeea7
commit
29b23dea97
90 changed files with 18002 additions and 10564 deletions
84
g10/signal.c
84
g10/signal.c
|
@ -1,5 +1,6 @@
|
|||
/* signal.c - signal handling
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
* 2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
|
@ -15,7 +16,8 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -26,22 +28,28 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#include "gpg.h"
|
||||
#include "options.h"
|
||||
#include "errors.h"
|
||||
#include "memory.h"
|
||||
#include "util.h"
|
||||
#include "main.h"
|
||||
#include "ttyio.h"
|
||||
|
||||
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
void init_signals(void) {}
|
||||
void pause_on_sigusr(int which) {}
|
||||
#else
|
||||
static volatile int caught_fatal_sig = 0;
|
||||
static volatile int caught_sigusr1 = 0;
|
||||
|
||||
static void
|
||||
init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
|
||||
{
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
#if defined(HAVE_SIGACTION) && defined(HAVE_STRUCT_SIGACTION)
|
||||
struct sigaction oact, nact;
|
||||
|
||||
|
@ -65,20 +73,8 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
|
|||
signal (sig, SIG_IGN);
|
||||
}
|
||||
#endif
|
||||
#endif /*!HAVE_DOSISH_SYSTEM*/
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_signal_name( int signum )
|
||||
{
|
||||
#if defined(SYS_SIGLIST_DECLARED) && defined(NSIG)
|
||||
return (signum >= 0 && signum < NSIG) ? sys_siglist[signum] : "?";
|
||||
#else
|
||||
return "some signal";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static RETSIGTYPE
|
||||
got_fatal_signal( int sig )
|
||||
{
|
||||
|
@ -89,14 +85,33 @@ got_fatal_signal( int sig )
|
|||
caught_fatal_sig = 1;
|
||||
|
||||
gcry_control (GCRYCTL_TERM_SECMEM );
|
||||
/* better don't transtale these messages */
|
||||
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
rl_free_line_state ();
|
||||
rl_cleanup_after_signal ();
|
||||
#endif
|
||||
|
||||
/* Better don't translate these messages. */
|
||||
write(2, "\n", 1 );
|
||||
s = "?" /* FIXME: log_get_name()*/; if( s ) write(2, s, strlen(s) );
|
||||
s = log_get_name(); if( s ) write(2, s, strlen(s) );
|
||||
write(2, ": ", 2 );
|
||||
s = get_signal_name(sig); write(2, s, strlen(s) );
|
||||
|
||||
#if HAVE_DECL_SYS_SIGLIST && defined(NSIG)
|
||||
s = (sig >= 0 && sig < NSIG) ? sys_siglist[sig] : "?";
|
||||
write (2, s, strlen(s) );
|
||||
#else
|
||||
write (2, "signal ", 7 );
|
||||
if (sig < 0 || sig >=100)
|
||||
write (2, "?", 1);
|
||||
else {
|
||||
if (sig >= 10)
|
||||
write (2, "0123456789"+(sig/10), 1 );
|
||||
write (2, "0123456789"+(sig%10), 1 );
|
||||
}
|
||||
#endif
|
||||
write(2, " caught ... exiting\n", 20 );
|
||||
|
||||
/* reset action to default action and raise signal again */
|
||||
/* Reset action to default action and raise signal again. */
|
||||
init_one_signal (sig, SIG_DFL, 0);
|
||||
dotlock_remove_lockfiles ();
|
||||
#ifdef __riscos__
|
||||
|
@ -116,7 +131,6 @@ got_usr_signal( int sig )
|
|||
void
|
||||
init_signals()
|
||||
{
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
init_one_signal (SIGINT, got_fatal_signal, 1 );
|
||||
init_one_signal (SIGHUP, got_fatal_signal, 1 );
|
||||
init_one_signal (SIGTERM, got_fatal_signal, 1 );
|
||||
|
@ -124,14 +138,12 @@ init_signals()
|
|||
init_one_signal (SIGSEGV, got_fatal_signal, 1 );
|
||||
init_one_signal (SIGUSR1, got_usr_signal, 0 );
|
||||
init_one_signal (SIGPIPE, SIG_IGN, 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pause_on_sigusr( int which )
|
||||
{
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
#if defined(HAVE_SIGPROCMASK) && defined(HAVE_SIGSET_T)
|
||||
sigset_t mask, oldmask;
|
||||
|
||||
|
@ -150,16 +162,15 @@ pause_on_sigusr( int which )
|
|||
while (!caught_sigusr1)
|
||||
sigpause(SIGUSR1);
|
||||
caught_sigusr1 = 0;
|
||||
sigrelse(SIGUSR1);
|
||||
#endif /*!HAVE_SIGPROCMASK && HAVE_SISET_T*/
|
||||
#endif
|
||||
sigrelse(SIGUSR1);
|
||||
#endif /*! HAVE_SIGPROCMASK && HAVE_SIGSET_T */
|
||||
}
|
||||
|
||||
|
||||
/* Disabled - see comment in tdbio.c:tdbio_begin_transaction() */
|
||||
#if 0
|
||||
static void
|
||||
do_block( int block )
|
||||
{
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
static int is_blocked;
|
||||
#if defined(HAVE_SIGPROCMASK) && defined(HAVE_SIGSET_T)
|
||||
static sigset_t oldmask;
|
||||
|
@ -179,14 +190,14 @@ do_block( int block )
|
|||
sigprocmask( SIG_SETMASK, &oldmask, NULL );
|
||||
is_blocked = 0;
|
||||
}
|
||||
#else /*!HAVE_SIGPROCMASK*/
|
||||
#else /*! HAVE_SIGPROCMASK && HAVE_SIGSET_T */
|
||||
|
||||
#if defined(NSIG)
|
||||
# define SIGSMAX (NSIG)
|
||||
#define SIGSMAX (NSIG)
|
||||
#elif defined(MAXSIG)
|
||||
# define SIGSMAX (MAXSIG+1)
|
||||
#define SIGSMAX (MAXSIG+1)
|
||||
#else
|
||||
# error "define SIGSMAX to the number of signals on your platform plus one"
|
||||
#error "define SIGSMAX to the number of signals on your platform plus one"
|
||||
#endif
|
||||
|
||||
static void (*disposition[SIGSMAX])(int);
|
||||
|
@ -208,11 +219,9 @@ do_block( int block )
|
|||
}
|
||||
is_blocked = 0;
|
||||
}
|
||||
#endif /*!HAVE_SIGPROCMASK*/
|
||||
#endif /*HAVE_DOSISH_SYSTEM*/
|
||||
#endif /*! HAVE_SIGPROCMASK && HAVE_SIGSET_T */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
block_all_signals()
|
||||
{
|
||||
|
@ -224,3 +233,6 @@ unblock_all_signals()
|
|||
{
|
||||
do_block(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HAVE_DOSISH_SYSTEM */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue