Date: Sat, 30 Dec 2017 21:39:00 +0700 From: Eugene Grosbein <eugen@grosbein.net> To: "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net> Cc: Ian Lepore <ian@freebsd.org>, Yuri <yuri@rawbw.com>, Freebsd hackers list <freebsd-hackers@freebsd.org> Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? Message-ID: <5A47A504.1030901@grosbein.net> In-Reply-To: <201712301406.vBUE68qD076011@pdx.rh.CN85.dnsmgr.net> References: <201712301406.vBUE68qD076011@pdx.rh.CN85.dnsmgr.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5A47A504.1030901>