Fix freopen so it resets stream buffer (#61)

This commit is contained in:
Justine Tunney 2021-03-07 12:12:02 -08:00
parent 7583b3accc
commit aad841610e
2 changed files with 68 additions and 0 deletions

View file

@ -46,6 +46,8 @@ FILE *freopen(const char *pathname, const char *mode, FILE *stream) {
dup3(fd, stream->fd, flags & O_CLOEXEC);
close(fd);
stream->iomode = flags;
stream->beg = 0;
stream->end = 0;
return stream;
} else {
return NULL;