Path: utzoo!utgpu!watmath!clyde!bellcore!rutgers!mailrus!ncar!ames!haven!mimsy!jds
From: jds@mimsy.UUCP (James da Silva)
Newsgroups: comp.unix.questions
Subject: Re: tail -f
Summary: sleep(1)
Keywords: how does it work
Message-ID: <14888@mimsy.UUCP>
Date: 7 Dec 88 16:33:34 GMT
References: <412@fedeva.UUCP>
Reply-To: jds@mimsy.umd.edu (James da Silva)
Organization: University of Maryland, Department of Computer Science
Lines: 21

In article <412@fedeva.UUCP> jbr0871@fedeva.UUCP (Blaine Robertson) writes:
>Can someone please tell me how 'tail -f' works?.  Obviously, it does not
>do a busy loop while doing a stat on the file.  I know that it has got
>to be blocked, waiting for the length to change, but how does it get
>notified of a change?  Thanks in advance for any responses.

Actually, tail doesn't get notified of a change.  It simply sleeps for a
second, then tries a read().  Probably something like this:

	while(1) {
		sleep(1);
		while(size=read(file,buffer,BSIZE))
			write(1,buffer,size);
	}

Nothing fancy, I'm afraid.

Jaime
...........................................................................
: domain: jds@mimsy.umd.edu				     James da Silva
: path:   uunet!mimsy!jds