Browse Source

When messing with fd NONBLOCK status, put things back the way we found
them afterwards. As was, this hosed things up for fds shared with a
parent process. Very bad for shells... Oops.
-Erik

Eric Andersen 23 years ago
parent
commit
4ba08b4526
1 changed files with 4 additions and 1 deletions
  1. 4 1
      libc/stdio/stdio.c

+ 4 - 1
libc/stdio/stdio.c

@@ -203,8 +203,11 @@ void __stdio_flush_buffers(void)
 	if (WRITEABLE(fp)) {
 	    /* Set the underlying fd to non-block mode to ensure
 	     * that calls to _exit() and abort() will not block */
-	    fcntl(fp->fd, F_SETFL, O_NONBLOCK);
+	    long flags;
+	    fcntl(fp->fd, F_GETFL, &flags);
+	    fcntl(fp->fd, F_SETFL, flags|O_NONBLOCK);
 	    fflush(fp);
+	    fcntl(fp->fd, F_SETFL, flags);
 	}
     }
 }