summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-02-23 06:02:02 +0000
committerEric Andersen <andersen@codepoet.org>2002-02-23 06:02:02 +0000
commit96da9a8ea6f3bcbceff92ae2293b4808b39dcdb2 (patch)
tree543f89b5f9fda7204013737d8edb6303a15c88f6 /libc/stdio/stdio.c
parent4893763f01647862a927c3335610d1a8cf2d390f (diff)
Per discussion with Manuel, when we call __stdio_flush_buffers
from abort() and from _exit(), we need to ensure that flushing will not cause us to block. So use fcntl to set the fd's to non-block mode...
Diffstat (limited to 'libc/stdio/stdio.c')
-rw-r--r--libc/stdio/stdio.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index 45cd0b8ec..eb2961f37 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -198,7 +198,15 @@ char _free_buffer_index = FIXED_BUFFERS;
*/
void __stdio_flush_buffers(void)
{
- fflush(NULL); /* Files will be closed on _exit call. */
+ FILE *fp;
+ for (fp = __IO_list; fp; fp = fp->next) {
+ 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);
+ fflush(fp);
+ }
+ }
}
/*