⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signal_handler.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
字号:
/**********Copyright 1990 Regents of the University of California.  All rights reserved.Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group**********//* * The signal routines for spice 3 and nutmeg. */#include "ngspice.h"#include "ifsim.h"#include "iferrmsg.h"#include "cpdefs.h"#include "ftedefs.h"#include "ftedev.h"#include <setjmp.h>#include <signal.h>#include "signal_handler.h"#ifdef HAVE_GNUREADLINE/* Added GNU Readline Support 11/3/97 -- Andrew Veliath <veliaa@rpi.edu> *//* from spice3f4 patch to ng-spice. jmr */#include <readline/readline.h>#include <readline/history.h>#endif#ifdef HAVE_BSDEDITLINE/* SJB added edit line support 2005-05-05 */#include <editline/readline.h>#endif /* HAVE_BSDEDITLINE */JMP_BUF jbuf;/* The (void) signal handlers... SIGINT is the only one that gets reset (by * cshpar) so it is global. They are ifdef BSD because of the sigmask * stuff in sigstop. We set the interrupt flag and return if ft_setflag * is TRUE. *//*  invoke this function upon keyboard interrupt  */RETSIGTYPEft_sigintr(void){  /*  fprintf (cp_err, "Received interrupt.  Handling it  . . . . .\n");  */  /* Reinstall ft_signintr as the signal handler. */  (void) signal( SIGINT, (SIGNAL_FUNCTION) ft_sigintr );    gr_clean();  /* Clean up plot window */    if (ft_intrpt)     /* check to see if we're being interrupted repeatedly */        fprintf(cp_err, "Interrupted again (ouch)\n");     else {        fprintf(cp_err, "Interrupted once . . .\n");         ft_intrpt = TRUE;    }    if (ft_setflag) {        return;     /* just return without aborting simulation if ft_setflag = TRUE */    }	/* sjb - what to do for editline???	   The following are not supported in editline */#if defined(HAVE_GNUREADLINE) 	/*  Clean up readline after catching signals  */        /*  One or all of these might be superfluous  */	(void) rl_free_line_state();	(void) rl_cleanup_after_signal();	(void) rl_reset_after_signal(); #endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */    /* To restore screen after an interrupt to a plot for instance */    cp_interactive = TRUE;    cp_resetcontrol();       /* here we jump to the start of command processing in main() after resetting everything.  */    LONGJMP(jbuf, 1);}RETSIGTYPEsigfloat(int sig, int code){    gr_clean();    fperror("Error", code);    rewind(cp_out);    (void) signal( SIGFPE, (SIGNAL_FUNCTION) sigfloat );    LONGJMP(jbuf, 1);}/* This should give a new prompt if cshpar is waiting for input.  */#    ifdef SIGTSTPRETSIGTYPEsigstop(void){    gr_clean();    cp_ccon(FALSE);    (void) signal(SIGTSTP, SIG_DFL);    (void) kill(getpid(), SIGTSTP); /* This should stop us */    return;}RETSIGTYPEsigcont(void){    (void) signal(SIGTSTP, (SIGNAL_FUNCTION) sigstop);    if (cp_cwait)        LONGJMP(jbuf, 1);}#    endif/* Special (void) signal handlers. */RETSIGTYPEsigill(void){    fprintf(cp_err, "\ninternal error -- illegal instruction\n");    fatal();}RETSIGTYPEsigbus(void){    fprintf(cp_err, "\ninternal error -- bus error\n");    fatal();}RETSIGTYPEsigsegv(void){    fprintf(cp_err, "\ninternal error -- segmentation violation\n");    fatal();}RETSIGTYPEsig_sys(void){    fprintf(cp_err,         "\ninternal error -- bad argument to system call\n");    fatal();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -