threads/79887: [patch] freopen() isn't thread-safe
David Xu
davidxu at freebsd.org
Wed Dec 28 20:20:07 PST 2005
The following reply was made to PR threads/79887; it has been noted by GNATS.
From: David Xu <davidxu at freebsd.org>
To: bug-followup at freebsd.org, tejblum at yandex-team.ru
Cc:
Subject: Re: threads/79887: [patch] freopen() isn't thread-safe
Date: Thu, 29 Dec 2005 12:16:01 +0800
Indeed, this a bug, but the patch you provided breaks the samentic the
FILE structure was designed for, here you conditionally call
fp->_close(), this is incorrect, because the hook may be an external
function, it should always be called to notify external code.
I think the right fix is to fix those code which is still using
STDERR_FILENO, or don't do following hack in freopen.c:
if (wantfd >= 0 && f != wantfd) {
if (_dup2(f, wantfd) >= 0) {
(void)_close(f);
f = wantfd;
}
}
This is not required by standard.
David Xu
More information about the freebsd-threads
mailing list