static void gimp_eek (const gchar *reason, const gchar *message, gboolean use_handler) { #ifndef G_OS_WIN32 g_printerr ("%s: %s: %s\n", gimp_filename_to_utf8 (full_prog_name), reason, message); if (use_handler) { switch (stack_trace_mode) { case GIMP_STACK_TRACE_NEVER: break; case GIMP_STACK_TRACE_QUERY: { sigset_t sigset; sigemptyset (&sigset); sigprocmask (SIG_SETMASK, &sigset, NULL); if (the_errors_gimp) gimp_gui_ungrab (the_errors_gimp); g_on_error_query (full_prog_name); } break; case GIMP_STACK_TRACE_ALWAYS: { sigset_t sigset; sigemptyset (&sigset); sigprocmask (SIG_SETMASK, &sigset, NULL); g_on_error_stack_trace (full_prog_name); } break; default: break; } } #else /* g_on_error_* don't do anything reasonable on Win32. */ MessageBox (NULL, g_strdup_printf ("%s: %s", reason, message), full_prog_name, MB_OK|MB_ICONERROR); #endif /* ! G_OS_WIN32 */ exit (EXIT_FAILURE); }
static void log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data) { g_log_default_handler(log_domain, log_level, message, unused_data); if((log_level & G_LOG_FLAG_FATAL) && NTask > 1) { g_on_error_stack_trace (""); abort(); } }
void sig_segfault_handler(int signo) { ADMImage_stat(); g_on_error_stack_trace ("avidemux"); printf("Memory stat:\n"); // g_on_error_query (programname); signo=0; // will keep GCC happy exit(1); // _exit(1) ??? }
static void G_GNUC_NORETURN fatal_signal_handler(int sig) { sigset_t sigset; sigemptyset(&sigset); sigprocmask(SIG_SETMASK, &sigset, NULL); g_print("\nLiferea did receive signal %d (%s).\n", sig, g_strsignal(sig)); g_print("You have probably triggered a program bug. I will now try to \n"); g_print("create a backtrace which you can attach to any support requests.\n\n"); g_on_error_stack_trace(PACKAGE); _exit(1); }
static void fault_spin (void) { int spinning = TRUE; glib_on_error_halt = FALSE; g_on_error_stack_trace ("gst-launch"); wait (NULL); /* FIXME how do we know if we were run by libtool? */ printf ("Spinning. Please run 'gdb gst-launch %d' to continue debugging, " "Ctrl-C to quit, or Ctrl-\\ to dump core.\n", (gint) getpid ()); while (spinning) g_usleep (1000000); }
AwnApplet * awn_applet_factory_initp (const gchar *name, gchar* uid, gint panel_id) { g_on_error_stack_trace (NULL); html_init (); WebApplet *webapplet = g_malloc (sizeof (WebApplet)); webapplet->uid=g_strdup(uid); webapplet->check_home = NULL; webapplet->location_dialog = NULL; webapplet->start = NULL; webapplet->applet = AWN_APPLET (awn_applet_simple_new (name, uid, panel_id)); init_config (webapplet); gint height = awn_applet_get_size(webapplet->applet); awn_applet_simple_set_icon_name(AWN_APPLET_SIMPLE(webapplet->applet), ICON_NAME); /*gtk_widget_show_all (GTK_WIDGET (webapplet->applet));*/ awn_html_dialog_new (webapplet); gtk_window_set_focus_on_map (GTK_WINDOW (webapplet->mainwindow), TRUE); g_signal_connect_after (G_OBJECT (webapplet->applet), "realize", G_CALLBACK (_bloody_thing_has_style), webapplet); return webapplet->applet; }
static void sigsegv_handler(int G_GNUC_UNUSED signum) { g_on_error_stack_trace(g_get_prgname()); abort(); /* trigger a SIGABRT instead of just exiting */ }
void g_on_error_query (const gchar *prg_name) { #ifndef G_OS_WIN32 static const gchar *query1 = "[E]xit, [H]alt"; static const gchar *query2 = ", show [S]tack trace"; static const gchar *query3 = " or [P]roceed"; gchar buf[16]; if (!prg_name) prg_name = g_get_prgname (); retry: if (prg_name) _g_fprintf (stdout, "%s (pid:%u): %s%s%s: ", prg_name, (guint) getpid (), query1, query2, query3); else _g_fprintf (stdout, "(process:%u): %s%s: ", (guint) getpid (), query1, query3); fflush (stdout); if (isatty(0) && isatty(1)) fgets (buf, 8, stdin); else strcpy (buf, "E\n"); if ((buf[0] == 'E' || buf[0] == 'e') && buf[1] == '\n') _exit (0); else if ((buf[0] == 'P' || buf[0] == 'p') && buf[1] == '\n') return; else if (prg_name && (buf[0] == 'S' || buf[0] == 's') && buf[1] == '\n') { g_on_error_stack_trace (prg_name); goto retry; } else if ((buf[0] == 'H' || buf[0] == 'h') && buf[1] == '\n') { while (glib_on_error_halt) ; glib_on_error_halt = TRUE; return; } else goto retry; #else if (!prg_name) prg_name = g_get_prgname (); MessageBox (NULL, "g_on_error_query called, program terminating", (prg_name && *prg_name) ? prg_name : NULL, MB_OK|MB_ICONERROR); _exit(0); #endif }