threads/79887: [patch] freopen() isn't thread-safe

David Xu davidxu at
Wed Dec 28 22:30:16 PST 2005

The following reply was made to PR threads/79887; it has been noted by GNATS.

From: David Xu <davidxu at>
To: Dmitrij Tejblum <tejblum at>
Cc: bug-followup at
Subject: Re: threads/79887: [patch] freopen() isn't thread-safe
Date: Thu, 29 Dec 2005 14:23:39 +0800

 Dmitrij Tejblum wrote:
 > Well, this is C, not C++, so there cannot be strict difference between 
 > allowed and disallowed. But the _close field is not required by any 
 > standarts (funopen() too) and is not documented by manpages (I checked 
 > manpages with grep). And there does exist documented interface for 
 > setting _close: funopen(). Thus _close is internal.
 Then why use the following code to close a file descriptor,
 if (isopen)
 	(void) (*fp->_close)(fp->_cookie);
 Why don't use _close(fp->_file)? this should be faster.
 This implies that someone can replace fp->_close with another function
 pointer,so that function must be called unconditionally. I think the
 libc should have a document to clarify this problem. Also should we move
 the PR to freebsd-standard@ list ?

More information about the freebsd-threads mailing list