Index: trunk/Ohana/src/opihi/lib.shell/gprint.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/gprint.c	(revision 17419)
+++ trunk/Ohana/src/opihi/lib.shell/gprint.c	(revision 18426)
@@ -134,5 +134,5 @@
   }
 
-  // check the special cases 
+  // check the special cases (do not close old file in these cases)
   if (stream[0].file == stdout) {
     stream[0].file = file;
@@ -243,9 +243,9 @@
   // we allow the user to set stdout to ERR and stderr to LOG if they want
   if (!strcmp (stream[0].name, "stdout")) {
-    stream[0].file = stdout;
+    gprintCloseFile (stream, stdout);
     return;
   }
   if (!strcmp (stream[0].name, "stderr")) {
-    stream[0].file = stderr;
+    gprintCloseFile (stream, stderr);
     return;
   }
@@ -254,8 +254,10 @@
   file = fopen (stream[0].name, "a");
   if (file == NULL) {
+    // XXX this is a problem: we are leaving open the old file
     fprintf (stderr, "cannot open file %s\n", stream[0].name);
     free (stream[0].name);
-    stream[0].file = (dest == GP_LOG) ? stdout : stderr;
+    file = (dest == GP_LOG) ? stdout : stderr;
     stream[0].name = (dest == GP_LOG) ? strcreate ("stdout") : strcreate("stderr");
+    gprintCloseFile (stream, file);
     return;
   }
