diff --git a/ChangeLog b/ChangeLog index 9196634e70..7b37a20784 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-07-17 Wim Taymans + + * docs/gst/gstreamer-sections.txt: + * gst/gst.c: (gst_segtrap_is_enabled), (gst_segtrap_set_enabled): + * gst/gst.h: + * gst/gstplugin.c: (_gst_plugin_fault_handler_restore): + Add two functions to check and change the SIGSEGV behaviour + when loading plugins. + Don't mess with the SIGSEGV handler when we were told not to. + Fixes #347794. + API: gst_segtrap_is_enabled + API: gst_segtrap_set_enabled + 2006-07-14 Wim Taymans * libs/gst/base/gstbasesrc.c: (gst_base_src_update_length): diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index cd872e8037..e827964221 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -25,6 +25,8 @@ gst_init_get_option_group gst_deinit gst_version gst_version_string +gst_segtrap_is_enabled +gst_segtrap_set_enabled diff --git a/gst/gst.c b/gst/gst.c index 7f3f544a85..7f7156767e 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -131,7 +131,6 @@ extern gint _gst_trace_on; /* set to TRUE when segfaults need to be left as is */ gboolean _gst_disable_segtrap = FALSE; - static void load_plugin_func (gpointer data, gpointer user_data); static gboolean init_pre (void); static gboolean init_post (void); @@ -1055,3 +1054,40 @@ gst_version_string () return g_strdup_printf ("GStreamer %d.%d.%d (prerelease)", major, minor, micro); } + +/** + * gst_segtrap_is_enabled: + * + * Some functions in the GStreamer core might install a custom SIGSEGV handler to + * better catch and report errors to the application. Currently this feature is + * enabled by default when loading plugins. + * + * Applications might want to disable this behaviour with the + * gst_segtrap_set_enabled() function. This is typically done if the application + * wants to install its own handler without GStreamer interfering. + * + * Returns: %TRUE if GStreamer is allowed to install a custom SIGSEGV handler. + * + * Since: 0.10.10 + */ +gboolean +gst_segtrap_is_enabled (void) +{ + /* yeps, it's enabled when it's not disabled */ + return !_gst_disable_segtrap; +} + +/** + * gst_segtrap_set_enabled: + * @enabled: whether a custom SIGSEGV handler should be installed. + * + * Applications might want to disable/enable the SIGSEGV handling of + * the GStreamer core. See gst_segtrap_is_enabled() for more information. + * + * Since: 0.10.10 + */ +void +gst_segtrap_set_enabled (gboolean enabled) +{ + _gst_disable_segtrap = !enabled; +} diff --git a/gst/gst.h b/gst/gst.h index 55f5df92dd..b2687691e3 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -85,6 +85,9 @@ void gst_version (guint *major, guint *minor, guint *micro, guint *nano); gchar * gst_version_string (void); +gboolean gst_segtrap_is_enabled (void); +void gst_segtrap_set_enabled (gboolean enabled); + G_END_DECLS #endif /* __GST_H__ */ diff --git a/gst/gstplugin.c b/gst/gstplugin.c index e2425f04dc..b59350e95a 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -279,6 +279,10 @@ _gst_plugin_fault_handler_restore (void) { struct sigaction action; + /* if asked to leave segfaults alone, just return */ + if (_gst_disable_segtrap) + return; + memset (&action, 0, sizeof (action)); action.sa_handler = SIG_DFL;