[comp.sources.d] PAX : Too many open files

jv@mhres.mh.nl (Johan Vromans) (02/19/89)

In article <6510@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) wrote:
> wietse@wzv.UUCP (Wietse Z. Venema) wrote:
> > Just found a mistake in the code; where closedir() should be called, the
> > program invokes the close() function...
> > 
> > < 		close(dirp);
> > ---
> > > 		closedir(dirp);
> 
> Note that the problem would've been found a long time ago had this program
> been checking the results of its system calls...  (Yes, Virginia, a "close()"
> CAN fail!)

This remembers me to one of the nice features of Burroughs
Extended Algol, running on B6700/B7700 mainframes.
In this language, you could check for the result of an IO
operation, and handle accordingly. If you did not check the
result, code to call a system-supplied exception handler was
inserted by the compiler. In all situations, exceptions were
trapped unless you explicitly ignored the result of the call,
e.g.: 
	result := read (......);
	% do nothing with 'result'

If you just called 'read(...)' the compiler generated code as if
you wrote:
	if read(...) then handleIOerror(...);

Of course, this is only possible because the IO operations were part
of the language, like in Pascal, and not a separate package, like
in C. 
But things like "unchecked system calls" did not exist .....
-- 
Johan Vromans			 jv@mh.nl via european backbone (mcvax)
Multihouse [A-Za-z ]* [NB]V			uucp: ..!mcvax!mh.nl!jv
Gouda - The Netherlands				  phone: +31 1820 62944

bet@dukeac.UUCP (Bennett Todd) (02/21/89)

I wanted to check all system calls no matter what, and yet not have to deal
with the clutter of error-checking in the (common) case where all I'm going to
do is give an error message and exit on failure. So I wrote libbent. Now, if I
don't want to deal with the possibility of failure explicitly in my code, I
just prepend 'e' to the routine I am about to call, and link with -lbent. I
recently posted libbent to comp.lang.c. Maybe, if I continue to get
encouraging feedback, I will post some subsequent version to
comp.sources.unix. 

-Bennett
bet@orion.mc.duke.edu

peter@ficc.uu.net (Peter da Silva) (02/21/89)

In article <2895@mhres.mh.nl>, jv@mhres.mh.nl (Johan Vromans) writes:
> Of course, this is only possible because the IO operations were part
> of the language, like in Pascal, and not a separate package, like
> in C. 

Nothing of the sort. You can implement libraries that work that way...
just design the calls that way:

	read(&status, fd, buf, nbytes); /* if status pointer == NULL,
					   call system error handler */
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.                 'U`
People have opinions. Companies have policy. And typos are my own business.