Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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

From: David Xu <davidxu@xxxxxxxxxxx>
To: bug-followup@xxxxxxxxxxx, tejblum@xxxxxxxxxxxxxx
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