From 827bfdd5050bda8ad8954d8231e7836dd7aac867 Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 15 Jul 2012 12:11:15 -0700 Subject: allow filters to terminate in arbitrary order; report best blame (not first blame) --- tools/hi-q.c | 143 ++++++++++++++++++++++++++++++++-------------------- tools/hi-test.c | 13 +++-- tools/hi-test.conf | 2 +- tools/hi-test2.conf | 3 ++ 4 files changed, 101 insertions(+), 60 deletions(-) create mode 100644 tools/hi-test2.conf diff --git a/tools/hi-q.c b/tools/hi-q.c index 914bb57..1896bf4 100644 --- a/tools/hi-q.c +++ b/tools/hi-q.c @@ -133,7 +133,6 @@ extern char** environ; int main(int argc, char** argv) { int verbose(1); int kidstatus; - pid_t somekid; int rslt; int loose_end = 0; @@ -207,6 +206,12 @@ int main(int argc, char** argv) { if (job.size()) filter.push_back(job); } unsigned int nkids = filter.size(); + +// Check for nothing to do. +// This is important, because the "last kid" is a special case. +// This makes it safe to assume that nkids-1 is non-negative. + if (nkids == 0) exit(0); // nothing to do + if (0 && verbose) for (unsigned int ii = 0; ii < nkids; ii++) { cerr << "hi-q filter[" << ii << "] :; "; for (VS::const_iterator token = filter[ii].begin(); @@ -407,51 +412,80 @@ int main(int argc, char** argv) { cerr << endl; } -// loop over N-1 kids ... _not_ including last kid - for (unsigned int ii=0; ii