Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/patch/e/E.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>

ulong
mtime(char *file)
{
	Dir *d;
	ulong mtime;

	d = dirstat(file);
	if(d == nil)
		sysfatal("can't dirstat file: %r");
	mtime = d->mtime;
	free(d);
	return mtime;
}

void
usage(void)
{
	fprint(2, "usage: E file ...\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	char *file;
	ulong otime;

	if(argc < 2)
		usage();
	file = argv[--argc];
	otime = mtime(file);
	if(fork() == 0)
		exec("/bin/B", argv);
	waitpid();
	for(;;){
		if(mtime(file) > otime)
			break;
		sleep(1000);
	}
	exits(nil);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].