summaryrefslogtreecommitdiff
path: root/tools/hi-q.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-20 12:15:59 -0700
committerJohn Denker <jsd@av8n.com>2012-07-20 12:15:59 -0700
commit6923595761a5006862bd785c63b35eb988543362 (patch)
tree144fcd365ccdc2842e4b99b5505a056b42f917a3 /tools/hi-q.c
parentd77d56ab050f7763f06461787cc862b6ec0095c4 (diff)
much smarter about exit status conventions
Diffstat (limited to 'tools/hi-q.c')
-rw-r--r--tools/hi-q.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/hi-q.c b/tools/hi-q.c
index f195508..369935e 100644
--- a/tools/hi-q.c
+++ b/tools/hi-q.c
@@ -68,6 +68,7 @@ foo_sa(TOOBIG, 98, "message was too big to process (see --max-size)"
void panic(const int sts) {
// FIXME: stop other children
+ cerr << "hi-q: panic called with " << sts << endl;
exit(sts);
}
@@ -171,7 +172,15 @@ int xclose(int arg){
extern char** environ;
-typedef enum {grey, black, qq, fail} moder;
+// meanings:
+// sa is a filter, using not-very-expressive exit codes: 0=ham 1=spam.
+// stub is not a filter; no stdin or stdout; just looks at environment.
+// series is a filter.
+// qq is not a filter, just an absorber.
+//
+// Note that series and stub use the same exit codes as qq.
+//
+typedef enum {series, stub, sa, qq, fail} moder;
class jobber{
public:
@@ -193,9 +202,9 @@ public:
void setmode(const string _mode) {
if (0) {}
- else if (_mode == "gray") mode = grey;
- else if (_mode == "grey") mode = grey; // variant spelling
- else if (_mode == "black") mode = black;
+ else if (_mode == "sa") mode = sa;
+ else if (_mode == "stub") mode = stub;
+ else if (_mode == "series") mode = series;
else if (_mode == "qq") mode = qq;
else {
cerr << "jobber: bad mode: " << _mode << endl;
@@ -310,7 +319,7 @@ bar
//xx fprintf(stderr, "Top of loop %d loose: %d\n", ii, loose_end);
int kid_end;
- if (filter[ii].mode != grey){
+ if (filter[ii].mode != stub){
int datapipe[2];
if (loose_end) {
@@ -396,7 +405,7 @@ bar
}
}
- if (filter[ii].mode != grey){
+ if (filter[ii].mode != stub){
close(loose_end); // the reading end is none of this kid's business
// except last kid: writing end
@@ -540,7 +549,7 @@ bar
string exword = "spam"; // default, for non-modern status codes
int excode = ex_spam; // default, for non-modern status codes
int sts = WEXITSTATUS(best_blame);
- if (filter[kidno].mode == grey) {
+ if (filter[kidno].mode != sa) {
exword = codemap[sts];
excode = sts;
}