Add two functions to check and change the SIGSEGV behaviour when loading plugins.
authorWim Taymans <wim.taymans@gmail.com>
Mon, 17 Jul 2006 17:40:52 +0000 (17:40 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 17 Jul 2006 17:40:52 +0000 (17:40 +0000)
Original commit message from CVS:
* 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

ChangeLog
docs/gst/gstreamer-sections.txt
gst/gst.c
gst/gst.h
gst/gstplugin.c

index 9196634..7b37a20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-07-17  Wim Taymans  <wim@fluendo.com>
+
+       * 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  <wim@fluendo.com>
 
        * libs/gst/base/gstbasesrc.c: (gst_base_src_update_length):
index cd872e8..e827964 100644 (file)
@@ -25,6 +25,8 @@ gst_init_get_option_group
 gst_deinit
 gst_version
 gst_version_string
+gst_segtrap_is_enabled
+gst_segtrap_set_enabled
 <SUBSECTION Private>
 </SECTION>
 
index 7f3f544..7f71567 100644 (file)
--- 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;
+}
index 55f5df9..b268769 100644 (file)
--- 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__ */
index e2425f0..b59350e 100644 (file)
@@ -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;