From owner-freebsd-hackers@freebsd.org Sat Dec 30 14:39:22 2017 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 2EB5CE8843D for ; Sat, 30 Dec 2017 14:39:22 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [78.47.246.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F6F67E56D; Sat, 30 Dec 2017 14:39:21 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (root@eg.sd.rdtc.ru [62.231.161.221] (may be forged)) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id vBUEd7ad048390 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 30 Dec 2017 15:39:08 +0100 (CET) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: freebsd-rwg@pdx.rh.CN85.dnsmgr.net Received: from [10.58.0.4] ([10.58.0.4]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTPS id vBUEd3l8004723 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 30 Dec 2017 21:39:03 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? To: "Rodney W. Grimes" References: <201712301406.vBUE68qD076011@pdx.rh.CN85.dnsmgr.net> Cc: Ian Lepore , Yuri , Freebsd hackers list From: Eugene Grosbein Message-ID: <5A47A504.1030901@grosbein.net> Date: Sat, 30 Dec 2017 21:39:00 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <201712301406.vBUE68qD076011@pdx.rh.CN85.dnsmgr.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00, LOCAL_FROM, RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 1.9 RDNS_NONE Delivered to internal network by a host with no rDNS * 2.6 LOCAL_FROM From my domains X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hz.grosbein.net 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: Sat, 30 Dec 2017 14:39:22 -0000 30.12.2017 21:06, Rodney W. Grimes wrote: >> Of course, there are cases when that's irrelevant, f.e. closing temporary file >> that is no more needed and being unlinked anyway. > > No error on close should be treated as irreleveant, they signify something > has gone wrong and itis best to inform the user and let the user decide > if this is irrelevant or not. > > Code that does not test return codes from EVERY single thing that can > return an error should be taken out back shown the danish axe, clean it > up or get it out of our tree! An application checks for error code after writing to stderr to report an error and finds it failed too; and what should be done then? :-) > One should never code to the "normal" conditions situation, it makes for > code that does not work well when the "abnormal" conditions arrise. > In real world, there are cases of temporary errors like some transient system resource shortage; application's own short timeout on close() because of NFS-server responding slow due to short network malfunction; temporary DNS failure etc. Not every such case deserves user attention as system must have some level of self-healing (retry, disregard etc.) > I would argue that in the above sample of "closing and unlinking" it > would actually be better to exit if the close failed possibly leaving > behind the evidence of why/what failed rather than blindling forging > ahead and potentially destroying the evidecnce by unlinking the file. > > If someone wants to go chasing after "failure to check exit codes" please > begin with /etc/rc.d/*, these scripts are so full of it I laugh every > time I see a system come up multiuser after 10+ errors have happendend > in them. Mostly it is NOT better to halt and sit instead of proceeding to multiuser anyway.