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

apapp@dgis.daitc.mil (Andy Papp) (02/10/89)

I have compiled the entire PAX suite, but it blows up on me giving the error
"Too many files open".  Has anyone else had this problem and solved it? I'm
running it on a VAX 11/780.

wietse@wzv.UUCP (Wietse Z. Venema) (02/12/89)

In article <339@daitc.daitc.mil> apapp@dgis.daitc.mil.UUCP (Andy Papp) writes:
>I have compiled the entire PAX suite, but it blows up on me giving the error
>"Too many files open".  Has anyone else had this problem and solved it? I'm
>running it on a VAX 11/780.

Just found a mistake in the code; where closedir() should be called, the
program invokes the close() function.  This is probably related to the
problem you describe. A patch follows at the end of this article.

*** namelist.c-	Mon Feb  6 23:25:20 1989
--- namelist.c	Sat Feb 11 20:03:29 1989
***************
*** 367,373 ****
  	    if (in_subdir) {
  		curr_dir->where = telldir(dirp);
  		pushdir(curr_dir);
! 		close(dirp);
  	    } 
  	    in_subdir++;
  
--- 367,373 ----
  	    if (in_subdir) {
  		curr_dir->where = telldir(dirp);
  		pushdir(curr_dir);
! 		closedir(dirp);
  	    } 
  	    in_subdir++;
  
-- 
work:	wswietse@eutrc3.uucp	| Eindhoven University of Technology
work:	wswietse@heitue5.bitnet	| Mathematics and Computing Science
home:	wietse@wzv.uucp		| 5600 MB Eindhoven, The Netherlands

gnu@hoptoad.uucp (John Gilmore) (02/13/89)

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!)
-- 
Copyright 1989 John Gilmore; you may redistribute only if your recipients may.
(Watergate, Stargate, and now BIXgate?  Copyleft your work to avoid abuse!)
John Gilmore    {sun,pacbell,uunet,pyramid,amdahl}!hoptoad!gnu    gnu@toad.com

tissot@nicaud.UUCP (Kevin Tissot) (02/13/89)

 I have the same problem on a SUN-2 system with SUN OS 3.4 - it works
for a while but then says 'Too many open files' and dumps core.


-- 
Kevin Tissot                                     / /~~~\ \
Nicolet Audiodiagnostics                        /|/ O O \|\
Madison, Wisconsin                              \|\  _  /|/
...uwvax!astroatc!nicmad!nicaud!tissot             \___/

wietse@wzv.UUCP (Wietse Z. Venema) (02/14/89)

gnu@hoptoad.uucp (John Gilmore) added:
>wietse@wzv.UUCP (Wietse Z. Venema) wrote:
>>
>> < 		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...  

This particular type of problems (wrong function/argument) can be found
even earlier by checking the result of lint(1).  Strongly recommended.
-- 
work:	wswietse@eutrc3.uucp	| Eindhoven University of Technology
work:	wswietse@heitue5.bitnet	| Mathematics and Computing Science
home:	wietse@wzv.uucp		| 5600 MB Eindhoven, The Netherlands