What does "no file" mean?

Joseph S. D. Yao jsdy at hadron.UUCP
Mon Jan 27 06:26:08 AEST 1986


The message "no file" comes from having too many open files, total,
among all your processes in the system.  Or, depending on your point
of view, too few compiled into the kernel.  The message comes from
the kernel.  Common causes include programs that open files and then
do not close them (aka sloppy programming), more users or programs
running than were originally expected, and/or a too-low assumption
of total #files available at system kernel compile time.

The problem can be easily repeated by:

/*
** Warning:  viewers at home are cautioned that the following
** should only be attempted by experienced professionals.  Any
** attempts to try this by children at home could result in a
** severely shortened life for either your system, your account,
** or you, depending on the penalties exacted by your system
** and Organization administration.
*/

#include <sys/param.h>
#include <sys/types.h>

#define ever	(;;)

#define DIRMODE	0755
#define FILMODE	0644

#define ERROR	(-1)

#define DUMPTIME 120	/* Max time this will run. */

char file[] = "tmp/00000000000000";

main()
{
	register char *cp;
	register int i, j, k;
	char *efile;
	int w, pid;
	time_t t, lim;
	extern time_t time();

	pid = getpid();
	(void) time(&t);
	lim = t + DUMPTIME;
	mkdir("tmp", DIRMODE);	/* left as a user exercise */
	cp = efile = &file[strlen(file)-1];

	for ever {
		(void) time(&t);
		if (t >= lim)
			break;
		for (i = 0; i < NOFILES; i++)
			(void) close(i);
		while (creat(file, FILMODE) >= 0) {
			while (*cp == 'z')
				*--cp = '0';
			++*cp;
			cp = efile;
		}
		switch (j = fork()) {
		  case ERROR:
			perror("fork");
			break;
		  case 0:	/* child -- go for more. */
			break;
		  default:
			while ((k = wait(&w)) != ERROR)
				if (k == j)
					break;
			break;
		}
	}
	for (i = 0; i < NOFILES; i++)
		(void) close(i);
	if (pid != getpid())
		return(1);
	execl("/bin/rm", "rm", "-rf", "tmp", 0);
	/* NOT REACHED */
	return(0);
}
-- 

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}



More information about the Comp.unix.wizards mailing list