summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fclose.c
blob: 8f0b4cef0b02227c529af04cc7768afbec98625c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <io.h>
#include <stdio.h>
#include <unistd.h>

int fclose(FILE *stream)
{
	if (fflush(stream) == -1)
		return -1;

	if (stream != stdin && stream != stdout && stream != stderr) {
		if (close(stream->fd) == -1)
			return -1;
	}

	return 0;
}