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);
125 if (retval == SIG_ERR)
127 fprintf(stderr,
"Unable to init signal %d ... exiting...\n", sig);
134 struct sigaction new_action,old_action;
135 memset(&new_action, 0,
sizeof(
struct sigaction));
138 new_action.sa_handler = signal_handler;
140 sigemptyset (&new_action.sa_mask);
142 new_action.sa_flags = SA_RESTART ;
144 int r=si_sigaction (sig, &new_action, &old_action);
148 fprintf(stderr,
"Unable to init signal %d ... exiting...\n", sig);
157#if defined(__linux__) && (defined(__i386) || defined(__amd64))
172 fprintf(stderr,
"Segment fault/Bus error occurred at %lx because of %lx (r:%d)\n"
173 "please inform the authors\n",
185 fputs(
"trying to restart...\n",stderr);
205void sigsegv_handler(
int sig,
int code,
struct sigcontext *scp,
char *addr)
207 fprintf(stderr,
"Singular : signal %d, code %d (v: %d):\n",
209 if ((sig!=SIGINT)&&(sig!=SIGABRT))
212 fprintf(stderr,
"Segment fault/Bus error occurred at %x (r:%d)\n"
213 "please inform the authors\n",
220 fputs(
"trying to restart...\n",stderr);
239 fprintf(stderr,
"Singular : signal %d (v: %d):\n",
244 fprintf(stderr,
"Segment fault/Bus error occurred (r:%d)\n"
245 "please inform the authors\n",
252 fputs(
"trying to restart...\n",stderr);
275 char default_opt=
' ';
277 && ((
char*)(
feOptSpec[FE_OPT_CNTRLC].value))[0])
278 { default_opt=((
char*)(
feOptSpec[FE_OPT_CNTRLC].value))[0]; }
288 else if (default_opt!=
' ')
294 fprintf(stderr,
"// ** Interrupt at cmd:`%s` in line:'%s'\n",
298 fputs(
"abort after this command(a), abort immediately(r), print backtrace(b), continue(c) or quit Singular(q) ?",stderr);
299 fflush(stderr);fflush(stdin);
316 fputs(
"** Warning: Singular should be restarted as soon as possible **\n",stderr);
325 fputs(
"** tried too often, try another possibility **\n",stderr);
338 while (c != EOF && c !=
'\n') c = fgetc(stdin);
386 char * args[4] = { (
char*)
"gdb", (
char*)
"Singular",
NULL,
NULL };
392 snprintf (
buf, 16,
"%d", getpid ());
402 fputs (
"\n\nquit with \"p si_stop_stack_trace_x=0\"\n\n\n",stderr);
406 fputs (
"stack_trace\n",stderr);
416 perror (
"could not fork");
426 execvp (args[0], args);
427 perror (
"exec failed");
440 int sel,
index, state;
444 if ((pipe (in_fd) == -1) || (pipe (out_fd) == -1))
446 perror (
"could open pipe");
453 si_close (0); si_dup2 (in_fd[0],0);
454 si_close (1); si_dup2 (out_fd[1],1);
455 si_close (2); si_dup2 (out_fd[1],2);
457 execvp (args[0], args);
458 perror (
"exec failed");
463 perror (
"could not fork");
468 FD_SET (out_fd[0], &fdset);
470 si_write (in_fd[1],
"backtrace\n", 10);
471 si_write (in_fd[1],
"p si_stop_stack_trace_x = 0\n", 28);
472 si_write (in_fd[1],
"quit\n", 5);
483 sel = si_select (FD_SETSIZE, &readset,
NULL,
NULL, &tv);
487 if ((sel > 0) && (FD_ISSET (out_fd[0], &readset)))
489 if (si_read (out_fd[0], &c, 1))
503 if ((c ==
'\n') || (c ==
'\r'))
506 fputs (buffer,stderr);
522 si_close (out_fd[0]);
523 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 si_hdl_typ si_sig_term_hdl
VAR volatile int si_stop_stack_trace_x
void sig_term_hdl_child(int)
VAR si_hdl_typ si_sig_chld_hdl
VAR volatile BOOLEAN do_shutdown
VAR si_hdl_typ old_sig_chld_hdl
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]
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)
#define si_siginterrupt(arg1, arg2)
int status int void * buf
BOOLEAN slClose(si_link l)
void sig_chld_hdl(int)
additional default signal handler