[project @ 2003-10-21 11:51:15 by stolz]
[ghc-hetmet.git] / ghc / rts / RtsUtils.c
index 8f6579c..6ff4f72 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsUtils.c,v 1.34 2003/04/01 15:40:27 sof Exp $
+ * $Id: RtsUtils.c,v 1.36 2003/10/21 11:51:15 stolz Exp $
  *
  * (c) The GHC Team, 1998-2002
  *
@@ -42,8 +42,8 @@ barf(char *s, ...)
   va_list ap;
   va_start(ap,s);
   /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
-  if (prog_argv != NULL && prog_argv[0] != NULL) {
-    fprintf(stderr, "%s: internal error: ", prog_argv[0]);
+  if (prog_argv != NULL && prog_name != NULL) {
+    fprintf(stderr, "%s: internal error: ", prog_name);
   } else {
     fprintf(stderr, "internal error: ");
   }
@@ -61,8 +61,8 @@ prog_belch(char *s, ...)
   va_list ap;
   va_start(ap,s);
   /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
-  if (prog_argv != NULL && prog_argv[0] != NULL) {
-    fprintf(stderr, "%s: ", prog_argv[0]);
+  if (prog_argv != NULL && prog_name != NULL) {
+    fprintf(stderr, "%s: ", prog_name);
   } 
   vfprintf(stderr, s, ap);
   fprintf(stderr, "\n");
@@ -249,7 +249,9 @@ setNonBlockingFd(int fd)
 
   /* clear the non-blocking flag on this file descriptor */
   fd_flags = fcntl(fd, F_GETFL);
-  fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK);
+  if (!(fd_flags & O_NONBLOCK)) {
+    fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK);
+  }
 }
 #else
 /* Stub defns -- async / non-blocking IO is not done