Re: Guppi 0.34.5 released



On Thu, May 04, 2000 at 09:03:05AM -0500, Jon Trowbridge wrote:
> On Thu, May 04, 2000 at 10:46:56AM -0400, Havoc Pennington wrote:
> > I think you want to close stdout then dup your devnull filedescriptor
> > to it.
> 
> <Insert Homer Simpson-style "Doh!" noise here>

Until I make a new release, here is a patch that will fix the problem.

-JT

-- 
GNU/Linux: Free your mind and your OS will follow.

--- Guppi-0.34.5/plug-ins/plot/boxplot/guppi-boxplot-item.c	Thu May  4 10:47:26 2000
+++ guppi3/plug-ins/plot/boxplot/guppi-boxplot-item.c	Thu May  4 10:42:06 2000
@@ -26,4 +26,6 @@
  */
 
+#include <unistd.h>
+#include <fcntl.h>
 #include "guppi-boxplot-item.h"
 #include "guppi-boxplot-state.h"
@@ -288,10 +290,14 @@ guppi_boxplot_item_update(GnomeCanvasIte
       /* This is *so* abusive; but libart_lgpl spews those damn
        colinear warning messages everywhere... */
-      static FILE* devnull = NULL;
-      FILE* stdout_copy = stdout;
-      if (devnull == NULL) 
-	devnull = fopen("/dev/null", "w");
-      stdout = devnull;
+      static int devnull = -1;
+      static int stdout_dup = -1;
 
+      if (devnull < 0)
+	devnull = open("/dev/null", O_WRONLY);
+      if (stdout_dup < 0)
+	stdout_dup = dup(STDOUT_FILENO);
+
+      close(STDOUT_FILENO);
+      dup2(devnull, STDOUT_FILENO);
       svp = art_svp_vpath_stroke(path,
 				 ART_PATH_STROKE_JOIN_ROUND,
@@ -299,6 +305,6 @@ guppi_boxplot_item_update(GnomeCanvasIte
 				 MAX(state->width, 0.25),
 				 4, 0.25);
-
-      stdout = stdout_copy;
+      fflush(stdout); /* This keeps FILE* buffering from screwing us up */
+      dup2(stdout_dup, STDOUT_FILENO);
     }
 


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