summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/freopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/freopen.c')
-rw-r--r--newlib/libc/stdio/freopen.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c
index 9010adcf7..6d54789da 100644
--- a/newlib/libc/stdio/freopen.c
+++ b/newlib/libc/stdio/freopen.c
@@ -71,6 +71,7 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <fcntl.h>
#include <stdlib.h>
#include "local.h"
+#include <sys/lock.h>
/*
* Re-direct an existing, open (probably) file to some other file.
@@ -150,6 +151,9 @@ _DEFUN (_freopen_r, (ptr, file, mode, fp),
fp->_flags = 0; /* set it free */
ptr->_errno = e; /* restore in case _close clobbered */
_funlockfile(fp);
+#ifndef __SINGLE_THREAD__
+ __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock);
+#endif
return NULL;
}