mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-28 16:43:09 +00:00
Add (FILE *) locking.
This commit is contained in:
parent
e33f599134
commit
32fc781e06
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53460
@ -35,7 +35,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)freopen.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)freopen.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$FreeBSD$";
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -45,6 +49,7 @@ static char sccsid[] = "@(#)freopen.c 8.1 (Berkeley) 6/4/93";
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <libc_private.h>
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,6 +70,8 @@ freopen(file, mode, fp)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLOCKFILE(fp);
|
||||||
|
|
||||||
if (!__sdidinit)
|
if (!__sdidinit)
|
||||||
__sinit();
|
__sinit();
|
||||||
|
|
||||||
@ -129,6 +136,7 @@ freopen(file, mode, fp)
|
|||||||
if (f < 0) { /* did not get it after all */
|
if (f < 0) { /* did not get it after all */
|
||||||
fp->_flags = 0; /* set it free */
|
fp->_flags = 0; /* set it free */
|
||||||
errno = sverrno; /* restore in case _close clobbered */
|
errno = sverrno; /* restore in case _close clobbered */
|
||||||
|
FUNLOCKFILE(fp);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,5 +159,6 @@ freopen(file, mode, fp)
|
|||||||
fp->_write = __swrite;
|
fp->_write = __swrite;
|
||||||
fp->_seek = __sseek;
|
fp->_seek = __sseek;
|
||||||
fp->_close = __sclose;
|
fp->_close = __sclose;
|
||||||
|
FUNLOCKFILE(fp);
|
||||||
return (fp);
|
return (fp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user