[gtk+] Move SIGPIPE suppression to gtk_init and document it



commit 97d15954ad426ea792e1c237dfefe754614a0e9e
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Oct 1 11:41:17 2009 -0400

    Move SIGPIPE suppression to gtk_init and document it
    
    Some people were unhappy with doing it deep inside the lpr print
    backend at an unpredictable time, and SIGPIPE is almost never
    wanted anyway.

 README.in                                      |    5 +++++
 gtk/gtkmain.c                                  |   11 +++++++++++
 modules/printbackends/lpr/gtkprintbackendlpr.c |    2 --
 3 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/README.in b/README.in
index bc2f857..84d6329 100644
--- a/README.in
+++ b/README.in
@@ -44,6 +44,11 @@ Release notes for 2.18
   GDK_NATIVE_WINDOWS makes GDK create a native X11 window for each
   GDK window, which might make problematic applications work better.
 
+* GTK+ calls signal (SIGPIPE, SIG_IGN) during initialization, to ignore
+  SIGPIPE signals, since these are almost never wanted in graphical
+  applications. If you do need to handle SIGPIPE for some reason, reset
+  the handler after gtk_init(), but notice that other libraries (e.g.
+  libdbus or gvfs) might do similar things.
 
 Release notes for 2.16
 ======================
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index e47e1be..2bbc96d 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -686,6 +686,8 @@ do_post_parse_initialization (int    *argc,
 
   gettext_initialization ();
 
+  signal (SIGPIPE, SIG_IGN);
+
   if (g_fatal_warnings)
     {
       GLogLevelFlags fatal_mask;
@@ -985,6 +987,15 @@ gtk_init_check (int	 *argc,
  * the GUI for some reason. If you want your program to fall back to a 
  * textual interface you want to call gtk_init_check() instead.
  * </para></note>
+ *
+ * <note><para>
+ * Since 2.18, GTK+ calls <literal>signal (SIGPIPE, SIG_IGN)</literal>
+ * during initialization, to ignore SIGPIPE signals, since these are
+ * almost never wanted in graphical applications. If you do need to
+ * handle SIGPIPE for some reason, reset the handler after gtk_init(),
+ * but notice that other libraries (e.g. libdbus or gvfs) might do
+ * similar things.
+ * </para></note>
  **/
 void
 gtk_init (int *argc, char ***argv)
diff --git a/modules/printbackends/lpr/gtkprintbackendlpr.c b/modules/printbackends/lpr/gtkprintbackendlpr.c
index eeaaa99..72d9c33 100644
--- a/modules/printbackends/lpr/gtkprintbackendlpr.c
+++ b/modules/printbackends/lpr/gtkprintbackendlpr.c
@@ -278,8 +278,6 @@ lpr_write (GIOChannel   *source,
     {
       gsize bytes_written;
 
-      signal (SIGPIPE, SIG_IGN);
-
       g_io_channel_write_chars (ps->in,
                                 buf, 
 				bytes_read, 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]