mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 02:36:11 +08:00
freopen: Added flush of the read buffers.
This commit is contained in:
committed by
Xiang Xiao
parent
d200cacc49
commit
ca9aeeec1f
@@ -100,9 +100,16 @@ FAR FILE *freopen(FAR const char *path, FAR const char *mode,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush the stream and duplicate the new fd to it */
|
/* Flush the stream and invalidate the read buffer. */
|
||||||
|
|
||||||
fflush(stream);
|
fflush(stream);
|
||||||
|
|
||||||
|
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
|
||||||
|
lib_rdflush(stream);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Duplicate the new fd to the stream. */
|
||||||
|
|
||||||
ret = dup2(fd, fileno(stream));
|
ret = dup2(fd, fileno(stream));
|
||||||
close(fd);
|
close(fd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user