Date: Thu, 29 Dec 2005 04:20:06 GMT From: David Xu <davidxu@freebsd.org> To: freebsd-threads@FreeBSD.org Subject: Re: threads/79887: [patch] freopen() isn't thread-safe Message-ID: <200512290420.jBT4K6Bo068277@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR threads/79887; it has been noted by GNATS.
From: David Xu <davidxu@freebsd.org>
To: bug-followup@freebsd.org, tejblum@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
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512290420.jBT4K6Bo068277>
