summaryrefslogtreecommitdiff
path: root/tools/hi-q.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-23 03:27:21 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-23 03:27:21 (GMT)
commit8164bf28464ad3e7628c422d6f02e3b515702d12 (patch)
tree72657534b46d2c4c16e589df498e7f9523330f2a /tools/hi-q.c
parent5b0852f0b2ddfd7d65711daf8602492a60917fbd (diff)
progress toward cleaning up logic of various modes and how the use their pipes
Diffstat (limited to 'tools/hi-q.c')
-rw-r--r--tools/hi-q.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/hi-q.c b/tools/hi-q.c
index 8766b08..39c68e3 100644
--- a/tools/hi-q.c
+++ b/tools/hi-q.c
@@ -425,13 +425,31 @@ bar
// For N-1 kids, the loose end feeds forward.
// It will be written by this kid and read by the next kid.
- // For the last kid, the loose end connects to hi-q.
- // It will be written by hi-q and read by the last kid.
-
- int lastkid = (ii == nkids-1);
- #define flip(a,b) (lastkid ? b : a)
- loose_end = datapipe[flip(rEnd, wEnd)];
- kid_end = datapipe[flip(wEnd, rEnd)];
+ // For the special kid, the loose end will be its nonstandard input.
+ // It will be written by us (hi-q) and read by the last kid.
+
+ switch (filter[ii].mode) {
+ case series:
+ case sa:
+ loose_end = datapipe[rEnd];
+ kid_end = datapipe[wEnd];
+ break;
+ case qq:
+ loose_end = datapipe[wEnd]; // reverse of normal "series" case
+ kid_end = datapipe[rEnd]; // reverse of normal "series" case
+ break;
+ case postspam:
+ case stub: // didn't need a connection at all
+ cerr << "ignoring fd " << datapipe[wEnd]
+ << " and " << datapipe[rEnd]
+ << endl;
+ xclose(datapipe[wEnd]);
+ xclose(datapipe[rEnd]);
+ break;
+ case fail:
+ cerr << "should never happen: invalid filter" << endl;
+ exeunt(ex_syserr);
+ }
}
kidpid[ii] = fork();