From owner-freebsd-hackers@freebsd.org Mon Jan 8 16:55:26 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0ECDE77659 for ; Mon, 8 Jan 2018 16:55:26 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 81DEA1EB6; Mon, 8 Jan 2018 16:55:26 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w08GtOkr022569; Mon, 8 Jan 2018 08:55:25 -0800 (PST) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w08GtO3D022568; Mon, 8 Jan 2018 08:55:24 -0800 (PST) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201801081655.w08GtO3D022568@pdx.rh.CN85.dnsmgr.net> Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? In-Reply-To: <5A5399AA.9020309@grosbein.net> To: Eugene Grosbein Date: Mon, 8 Jan 2018 08:55:24 -0800 (PST) CC: Eric van Gyzen , Brooks Davis , Alan Somers , Yuri , Ian Lepore , Freebsd hackers list X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Mailman-Approved-At: Mon, 08 Jan 2018 18:57:04 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 16:55:26 -0000 > 08.01.2018 23:13, Eric van Gyzen wrote: > > > Right, which is the reason such bugs are hard to diagnose. Optionally > > killing the process on close->EBADF would help find buggy code when > > another thread did NOT re-open the file descriptor between the two close > > calls. > > Wouldn't "close(f); assert(errno != EBADF);" be better? Or even #ifdef DEBUG_CLOSE #define close(f) close(f); assert(errno != EBADF); #endif Then the people that want to go chasing these errors can, and the rest of us are untouched. -- Rod Grimes rgrimes@freebsd.org