C port of E functionality from Plan 9 from User Space. This is especially useful for Mercurial users who wish to use acme/sam when editing changelog messages. Notes: Mon Apr 25 14:19:07 EDT 2011 geoff not worth a C program; done as an rc script instead. Reference: /n/sources/patch/sorry/e Date: Sun Apr 24 22:13:55 CES 2011 Signed-off-by: sstallion@gmail.com Reviewed-by: geoff --- /sys/src/cmd/E.c Thu Jan 1 00:00:00 1970 +++ /sys/src/cmd/E.c Sun Apr 24 22:12:36 2011 @@ -0,0 +1,44 @@ +#include +#include + +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); +}