30#if defined(__OPTIMIZE__) && defined(CALL_GDB)
34 #ifdef TIME_WITH_SYS_TIME
36 #ifdef HAVE_SYS_TIME_H
40 #ifdef HAVE_SYS_TIME_H
46 #ifdef HAVE_SYS_TIMES_H
47 #include <sys/times.h>
54 static void debug (
int);
122 if (retval == SIG_ERR)
124 fprintf(stderr,
"Unable to init signal %d ... exiting...\n", sig);
131 struct sigaction new_action,old_action;
132 memset(&new_action, 0,
sizeof(
struct sigaction));
135 new_action.sa_handler = signal_handler;
137 sigemptyset (&new_action.sa_mask);
139 new_action.sa_flags = SA_RESTART;
141 int r=si_sigaction (sig, &new_action, &old_action);
145 fprintf(stderr,
"Unable to init signal %d ... exiting...\n", sig);
154#if defined(__linux__) && (defined(__i386) || defined(__amd64))
169 fprintf(stderr,
"Segment fault/Bus error occurred at %lx because of %lx (r:%d)\n"
170 "please inform the authors\n",
182 fputs(
"trying to restart...\n",stderr);
202void sigsegv_handler(
int sig,
int code,
struct sigcontext *scp,
char *addr)
204 fprintf(stderr,
"Singular : signal %d, code %d (v: %d):\n",
206 if ((sig!=SIGINT)&&(sig!=SIGABRT))
209 fprintf(stderr,
"Segment fault/Bus error occurred at %x (r:%d)\n"
210 "please inform the authors\n",
217 fputs(
"trying to restart...\n",stderr);
236 fprintf(stderr,
"Singular : signal %d (v: %d):\n",
241 fprintf(stderr,
"Segment fault/Bus error occurred (r:%d)\n"
242 "please inform the authors\n",
249 fputs(
"trying to restart...\n",stderr);
272 char default_opt=
' ';
274 && ((
char*)(
feOptSpec[FE_OPT_CNTRLC].value))[0])
275 { default_opt=((
char*)(
feOptSpec[FE_OPT_CNTRLC].value))[0]; }
285 else if (default_opt!=
' ')
291 fprintf(stderr,
"// ** Interrupt at cmd:`%s` in line:'%s'\n",
295 fputs(
"abort after this command(a), abort immediately(r), print backtrace(b), continue(c) or quit Singular(q) ?",stderr);
296 fflush(stderr);fflush(stdin);
313 fputs(
"** Warning: Singular should be restarted as soon as possible **\n",stderr);
322 fputs(
"** tried too often, try another possibility **\n",stderr);
335 while (c != EOF && c !=
'\n') c = fgetc(stdin);
383 char * args[4] = { (
char*)
"gdb", (
char*)
"Singular",
NULL,
NULL };
389 sprintf (
buf,
"%d", getpid ());
399 fputs (
"\n\nquit with \"p si_stop_stack_trace_x=0\"\n\n\n",stderr);
403 fputs (
"stack_trace\n",stderr);
413 perror (
"could not fork");
423 execvp (args[0], args);
424 perror (
"exec failed");
437 int sel,
index, state;
441 if ((pipe (in_fd) == -1) || (pipe (out_fd) == -1))
443 perror (
"could open pipe");
450 si_close (0); si_dup2 (in_fd[0],0);
451 si_close (1); si_dup2 (out_fd[1],1);
452 si_close (2); si_dup2 (out_fd[1],2);
454 execvp (args[0], args);
455 perror (
"exec failed");
460 perror (
"could not fork");
465 FD_SET (out_fd[0], &fdset);
467 si_write (in_fd[1],
"backtrace\n", 10);
468 si_write (in_fd[1],
"p si_stop_stack_trace_x = 0\n", 28);
469 si_write (in_fd[1],
"quit\n", 5);
480 sel = si_select (FD_SETSIZE, &readset,
NULL,
NULL, &tv);
484 if ((sel > 0) && (FD_ISSET (out_fd[0], &readset)))
486 if (si_read (out_fd[0], &c, 1))
500 if ((c ==
'\n') || (c ==
'\r'))
503 fputs (buffer,stderr);
519 si_close (out_fd[0]);
520 si_close (out_fd[1]);
VAR jmp_buf si_start_jmpbuf
static void stack_trace(char *const *args)
VAR BOOLEAN singular_in_batchmode
si_hdl_typ si_set_signal(int sig, si_hdl_typ signal_handler)
meta function for binding a signal to an handler
VAR volatile int si_stop_stack_trace_x
VAR volatile BOOLEAN do_shutdown
VAR volatile int defer_shutdown
VAR int sigint_handler_cnt
void sigsegv_handler(int sig)
static void debug_stop(char *const *args)
void init_signals()
init signal handlers and error handling for libraries: NTL, factory
const CanonicalForm int s
void WerrorS(const char *s)
static void * feOptValue(feOptIndex opt)
EXTERN_VAR struct fe_option feOptSpec[]
VAR char my_yylinebuf[80]
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
VAR BOOLEAN fe_is_raw_tty
Voice * feInitStdin(Voice *pp)
const char * Tok2Cmdname(int tok)
This file provides miscellaneous functionality.
int dReportError(const char *fmt,...)
static int index(p_Length length, p_Ord ord)
int status int void * buf
#define si_siginterrupt(arg1, arg2)
BOOLEAN slClose(si_link l)
void sig_chld_hdl(int)
additional default signal handler