From: "Steve Simon" <steve@quintile.net>
To: 9fans@cse.psu.edu
Subject: [9fans] watch
Date: Tue, 19 Apr 2005 10:07:36 +0100 [thread overview]
Message-ID: <c76c8f03e8c09a6c0c77989570b0425b@quintile.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 48 bytes --]
watch and wrapper that I use attached.
-Steve
[-- Attachment #2: revu --]
[-- Type: text/plain, Size: 104 bytes --]
#!/bin/rc
cmd=`{doctype $*}
while(){
$cmd | proof &
watch $* > /dev/null && slay proof | rc
}
[-- Attachment #3: watch.c --]
[-- Type: text/plain, Size: 825 bytes --]
/* watch.c - await first file is modified, then cat all files */
#include <u.h>
#include <libc.h>
void
main(int argc, char *argv[])
{
char buf[4096];
int fd, i, n;
Dir *ods, *ds;
if (argc != 2){
fprint(2, "usage: await <file>\n");
exits("usage");
}
if ((ods = dirstat(argv[1])) == nil)
sysfatal("%s - cannot stat\n", argv[1]);
while(1){
sleep(1);
if ((ds = dirstat(argv[1])) == nil)
sysfatal("%s cannot stat %r\n", argv[1]);
if (ds->mtime > ods->mtime)
break;
free(ds);
}
for (i = 1; i < argc; i++){
if ((fd = open(argv[i], OREAD)) == -1)
fprint(2, "%s cannot open - %r\n", argv[i]);
while((n = read(fd, buf, sizeof(buf))) > 0)
if (write(1, buf, n) != n)
sysfatal("%s write failed - %r\n", argv[i]);
close(fd);
}
exits(0);
}
reply other threads:[~2005-04-19 9:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c76c8f03e8c09a6c0c77989570b0425b@quintile.net \
--to=steve@quintile.net \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).