TheGNUGeneralPublicLicenseisoftenshippedwithGNUsoftware,and isgenerallykeptinafilecalledCOPYINGorLICENSE.Ifyoudonot haveacopyofthelicense,writetotheFreeSoftwareFoundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #define READLINE_LIBRARY
#ifdefined (HAVE_CONFIG_H) # include "config_readline.h" #endif
#include <stdio.h> /* Just for NULL. Yuck. */ #include <sys/types.h> #include <signal.h>
#ifdefined (HAVE_UNISTD_H) # include <unistd.h> #endif/* HAVE_UNISTD_H */
/* System-specific feature definitions and include files. */ #include"rldefs.h"
#ifdefined (GWINSZ_IN_SYS_IOCTL) # include <sys/ioctl.h> #endif/* GWINSZ_IN_SYS_IOCTL */
#ifdefined (HANDLE_SIGNALS) /* Some standard library routines. */ #include"readline.h" #include"history.h"
/* This typedef is equivalent to the one for Function; it allows us
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */ typedef RETSIGTYPE SigHandler ();
/* If non-zero, readline will install its own signal handlers for
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */ int rl_catch_signals = 1;
/* If non-zero, readline will install a signal handler for SIGWINCH. */ #ifdef SIGWINCH int rl_catch_sigwinch = 1; #else int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */ #endif
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) /* Since the signal will not be blocked while we are in the signal
handler, ignore it until rl_clear_signals resets the catcher. */ # ifdefined (SIGALRM) if (sig == SIGINT || sig == SIGALRM) # else if (sig == SIGINT) # endif
rl_set_sighandler (sig, SIG_IGN, &dummy_cxt); #endif/* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
switch (sig)
{ case SIGINT:
rl_free_line_state (); /* FALLTHROUGH */
case SIGTERM: #ifdefined (SIGTSTP) case SIGTSTP: case SIGTTOU: case SIGTTIN: #endif/* SIGTSTP */ #ifdefined (SIGALRM) case SIGALRM: #endif #ifdefined (SIGQUIT) case SIGQUIT: #endif
rl_cleanup_after_signal ();
/* We don't want to change old_winch -- it holds the state of SIGWINCH dispositionsetbythecallingapplication.Weneedthisstate becausewecalltheapplication'sSIGWINCHhandlerafterupdating
our own idea of the screen size. */
rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch); #endif
/* If another sigwinch handler has been installed, call it. */
oh = (SigHandler *)old_winch.sa_handler; if (oh && oh != (SigHandler *)SIG_IGN && oh != (SigHandler *)SIG_DFL)
(*oh) (sig);
/* Set up a readline-specific signal handler, saving the old signal informationinOHANDLER.Returntheoldsignalhandler,like
signal(). */ static SigHandler *
rl_set_sighandler (sig, handler, ohandler) int sig;
SigHandler *handler;
sighandler_cxt *ohandler;
{
sighandler_cxt old_handler; #ifdefined (HAVE_POSIX_SIGNALS) struct sigaction act;
/* XXX -- assume we have memcpy */ /* If rl_set_signals is called twice in a row, don't set the old handler to
rl_signal_handler, because that would cause infinite recursion. */ if (handler != rl_signal_handler || old_handler.sa_handler != rl_signal_handler)
memcpy (ohandler, &old_handler, sizeof (sighandler_cxt));
#ifdefined (SIGALRM)
oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm); if (oh == (SigHandler *)SIG_IGN)
rl_sigaction (SIGALRM, &old_alrm, &dummy); #ifdefined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART) /* If the application using readline has already installed a signal handlerwithSA_RESTART,SIGALRMwillcausereadstoberestarted automatically,soreadlineshouldjustgetoutoftheway.Since
we tested for SIG_IGN above, we can just test for SIG_DFL here. */ if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
rl_sigaction (SIGALRM, &old_alrm, &dummy); #endif/* HAVE_POSIX_SIGNALS */ #endif/* SIGALRM */
/* Clean up the terminal and readline state after catching a signal, before
resending it to the calling application. */ void
rl_cleanup_after_signal ()
{
_rl_clean_up_for_exit (); if (rl_deprep_term_function)
(*rl_deprep_term_function) ();
rl_clear_pending_input ();
rl_clear_signals ();
}
/* Reset the terminal and readline state after a signal handler returns. */ void
rl_reset_after_signal ()
{ if (rl_prep_term_function)
(*rl_prep_term_function) (_rl_meta_flag);
rl_set_signals ();
}
/* Free up the readline variable line state for the current line (undo list, anypartialhistoryentry,anykeyboardmacrosinprogress,andany numericargumentsinprocess)aftercatchingasignal,beforecalling
rl_cleanup_after_signal(). */ void
rl_free_line_state ()
{ register HIST_ENTRY *entry;
rl_free_undo_list ();
entry = current_history (); if (entry)
entry->data = (char *)NULL;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.