[net.unix-wizards] What does "no file" mean?

perl@rdin.UUCP (Robert Perlberg) (01/23/86)

On several (rare) occasions I have seen the message "no file" appear on
the console on almost every implementation of UNIX I've ever worked
on.  I can never track down what causes it.  Once I had a program that
would always trigger the message.  I don't remember how I fixed it, but
it was mostly just luck and code juggling.  Now I have a system that
occasionally goes "no file" several times and then goes funny (can't
seem to find commands, can't make pipes, quit (^|) doesn't work, etc.)
until I reboot it.  No vendor I've spoken to can tell me what "no file"
means.  I don't have source code.  Could someone who does do a grep on
"no file" and tell me where this stuff is coming from and what it
means?

Robert Perlberg
Resource Dynamics Inc.
New York
{philabs|delftcc}!rdin!perl

jsdy@hadron.UUCP (Joseph S. D. Yao) (01/26/86)

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@seismo.{CSS.GOV,ARPA,UUCP}

wescott@sauron.UUCP (Michael Wescott) (01/28/86)

In article <526@rdin.UUCP> perl@rdin.UUCP (Robert Perlberg) writes:
> Could someone who does do a grep on
> "no file" and tell me where this stuff is coming from and what it
> means?

In SysV2r2 as well as bunch of other systems, the kernel prints this
message on the system console device when it has run out of file
structures.  There are too many open files or the kernel has a bug
and "loses" file structures.

Depending on your vendor, you may be able to remake your kernel
with more file structures.

	-Mike Wescott
	ncrcae!wescott