Index: trunk/Ohana/src/opihi/lib.shell/gprint.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/gprint.c	(revision 7917)
+++ trunk/Ohana/src/opihi/lib.shell/gprint.c	(revision 7929)
@@ -77,5 +77,5 @@
     return (&streams[i]);
   }
-  fprintf (STDERR, "programming error: gprintInit not called for thread\n");
+  fprintf (stderr, "programming error: gprintInit not called for thread\n");
   abort ();
 }
@@ -90,5 +90,9 @@
   if (stream[0].file != NULL) {
     fflush (stream[0].file);
-    if (stream[0].file != stdout) fclose (stream[0].file);
+    if (stream[0].file == stdout) goto skip_close;
+    if (stream[0].file == stderr) goto skip_close;
+    fclose (stream[0].file);
+
+  skip_close:
     stream[0].file = NULL;
   }
@@ -146,5 +150,5 @@
   stream[0].file = fopen (filename, "a");
   if (stream[0].file == NULL) {
-    fprintf (STDERR, "cannot open file %s\n", filename);
+    fprintf (stderr, "cannot open file %s\n", filename);
     stream[0].file = (dest == GP_LOG) ? stdout : stderr;
   }
