From owner-cvs-src-old@FreeBSD.ORG Thu Dec 9 20:28:53 2010 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 700AF106566C for ; Thu, 9 Dec 2010 20:28:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5E87F8FC17 for ; Thu, 9 Dec 2010 20:28:53 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id oB9KSrvj035657 for ; Thu, 9 Dec 2010 20:28:53 GMT (envelope-from jhb@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id oB9KSrxi035656 for cvs-src-old@freebsd.org; Thu, 9 Dec 2010 20:28:53 GMT (envelope-from jhb@repoman.freebsd.org) Message-Id: <201012092028.oB9KSrxi035656@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to jhb@repoman.freebsd.org using -f From: John Baldwin Date: Thu, 9 Dec 2010 20:28:30 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/lib/libc/stdio freopen.c X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2010 20:28:53 -0000 jhb 2010-12-09 20:28:30 UTC FreeBSD src repository Modified files: lib/libc/stdio freopen.c Log: SVN rev 216334 on 2010-12-09 20:28:30Z by jhb When reopening a stream backed by an open file descriptor, do not close the existing file descriptor. Instead, let dup2() atomically close the old file descriptor when assigning the newly opened file to the same descriptor. This closes a race in a multithreaded application where a concurrent open() could allocate the existing file descriptor in between the calls to close() and dup2(). PR: threads/79887 Submitted by: Dmitrij Tejblum tejblum of yandex-team.ru Reviewed by: davidxu MFC after: 1 week Revision Changes Path 1.22 +9 -12 src/lib/libc/stdio/freopen.c