From 05a4d855f167ae2d0d2c0ba0e386d933172b71ea Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 26 Mar 2007 20:55:26 +0000 Subject: add page (Kris Maglione) --- src/cmd/page/filter.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/cmd/page/filter.c') diff --git a/src/cmd/page/filter.c b/src/cmd/page/filter.c index 319cfb68..415db038 100644 --- a/src/cmd/page/filter.c +++ b/src/cmd/page/filter.c @@ -1,9 +1,9 @@ #include #include #include -#include -#include +#include #include +#include #include "page.h" Document* @@ -24,7 +24,7 @@ initfilt(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf, char *type, cha if(docopy){ if(pipe(p) < 0){ fprint(2, "pipe fails: %r\n"); - exits("Epipe"); + threadexits("Epipe"); } }else{ p[0] = open("/dev/null", ORDWR); @@ -35,27 +35,29 @@ initfilt(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf, char *type, cha switch(fork()){ case -1: fprint(2, "fork fails: %r\n"); - exits("Efork"); + threadexits("Efork"); default: - close(p[1]); + close(p[0]); if(docopy){ - write(p[0], buf, nbuf); + write(p[1], buf, nbuf); if(b) while((n = Bread(b, xbuf, sizeof xbuf)) > 0) - write(p[0], xbuf, n); + write(p[1], xbuf, n); else while((n = read(stdinfd, xbuf, sizeof xbuf)) > 0) - write(p[0], xbuf, n); + write(p[1], xbuf, n); } - close(p[0]); + close(p[1]); waitpid(); break; case 0: - close(p[0]); - dup(p[1], 0); + close(p[1]); + dup(p[0], 0); dup(ofd, 1); /* stderr shines through */ - execl("/bin/rc", "rc", "-c", cmd, nil); + if(chatty) + fprint(2, "Execing '%s'\n", cmd); + execlp("rc", "rc", "-c", cmd, nil); break; } @@ -81,7 +83,7 @@ initdvi(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf) */ if(b == nil){ /* standard input; spool to disk (ouch) */ fd = spooltodisk(buf, nbuf, &name); - sprint(fdbuf, "/fd/%d", fd); + sprint(fdbuf, "/dev/fd/%d", fd); b = Bopen(fdbuf, OREAD); if(b == nil){ fprint(2, "cannot open disk spool file\n"); -- cgit v1.2.3