Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!sun-barr!newstop!sun!grapevine!johnz From: johnz@grapevine.uucp (John Zolnowsky ext. 33230) Newsgroups: comp.os.minix Subject: Re: POSIX Summary: POSIX-compliant crashes Message-ID: <34633@grapevine.uucp> Date: 27 Oct 89 23:27:08 GMT References: <3819@ast.cs.vu.nl> <1989Oct26.143100.4916@world.std.com> <2091@prune.bbn.com> Sender: johnz@grapevine.EBay (John Zolnowsky ext. 33230) Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 33 In article <2091@prune.bbn.com>, rsalz@bbn.com (Rich Salz) writes: > In <3842@math.cs.vu.nl> ast@cs.vu.nl (Andy Tanenbaum) writes: > >Perhaps it wasn't a bug previously, but has to be regarded as a bug now > >because POSIX explicitly requires a call to closedir() with a rotten > >argument to return EBADF, not to crash, trap or do anything else. (See > >Sec. 5.1.2.4 of P1003.1). > > If closedir() is not implemented as a syscall, then the only portable > way to handle this is to keep a list of everything you ever opendir'd, > and a flag as to whether it's still valid or not. > > Posix blew it on this one; they should have defined it to be undefined > action. POSIX is full of "legalese" for these cases. The EBADF case mentioned above, for instance, is prefaced by the conditional: "For each of the following conditions, *when* [emphasis added -JZ] the condition is detected, the closedir() function shall return -1 and set errno ..." Section 2.5 Error Numbers further clarifies this in the fourth paragraph: "Implementations may support additional errors not included in this list, may generate errors in this list under circumstances other than those described here, or may contain extensions or *limitations* [emphasis added -JZ] that prevent some errors from occurring." POSIX defines the behavior of a conforming program. A program which closedirs a DIR pointer twice is non-conforming, and the behavior of the implementation need not be meaningful, useful, or even helpful. -JZ ---------------------------------------------------------------------- John Zolnowsky johnz@EBay.Sun.COM or ...!sun!johnz