shithub: 9intro

ref: a351bcdccdf5a4273bc8dc3360a48fbb8b8aa9ea
dir: /progs/poll.c.ms/

View raw version
.P1
.ps -1
.ti -1i
.B
.BX poll.c
.ps +1
.CW
.ps -2
.vs .15i
#include <u.h>
#include <libc.h>

void
main(int argc, char* argv[])
{
	Dir*	d;
	ulong	mtime, nmtime;

	if (argc != 2){
		fprint(2, "usage: %s file\en", argv[0]);
		exits("usage");
	}
	d = dirstat(argv[1]);
	if (d == nil)
		sysfatal("dirstat: %r");
	mtime = d->mtime;
	free(d);
	do {
		d = dirstat(argv[1]);
		if (d == nil)
			break;
		nmtime = d->mtime;
		free(d);
	} while(nmtime == mtime);
	print("%s changed\en", argv[1]);
	exits(nil);
}
.ps +2
.P2