aboutsummaryrefslogtreecommitdiffstats
path: root/libc/stdio/freopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio/freopen.c')
-rw-r--r--libc/stdio/freopen.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libc/stdio/freopen.c b/libc/stdio/freopen.c
index 59b222864..da3a674c9 100644
--- a/libc/stdio/freopen.c
+++ b/libc/stdio/freopen.c
@@ -59,6 +59,8 @@ freopen(const char *file, const char *mode, FILE *fp)
if (!__sdidinit)
__sinit();
+ FLOCKFILE(fp);
+
/*
* There are actually programs that depend on being able to "freopen"
* descriptors that weren't originally open. Keep this from breaking.
@@ -120,6 +122,7 @@ freopen(const char *file, const char *mode, FILE *fp)
if (f < 0) { /* did not get it after all */
fp->_flags = 0; /* set it free */
+ FUNLOCKFILE(fp);
errno = sverrno; /* restore in case _close clobbered */
return (NULL);
}
@@ -154,5 +157,6 @@ freopen(const char *file, const char *mode, FILE *fp)
*/
if (oflags & O_APPEND)
(void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
+ FUNLOCKFILE(fp);
return (fp);
}