summaryrefslogtreecommitdiff
path: root/tools/hi-q.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-20 17:02:38 -0700
committerJohn Denker <jsd@av8n.com>2012-07-29 15:32:35 -0700
commit4e298a27d17d0d0a4181b302b4237363396eb0ed (patch)
tree1cf9de80a7de193f293710dcf21cec05f7eab625 /tools/hi-q.c
parenteb342191804df42d294e1579a880c58dd213d66d (diff)
more regularization of reporting
Diffstat (limited to 'tools/hi-q.c')
-rw-r--r--tools/hi-q.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/tools/hi-q.c b/tools/hi-q.c
index f6b57e1..26e67a7 100644
--- a/tools/hi-q.c
+++ b/tools/hi-q.c
@@ -258,12 +258,11 @@ void usage() {
string progname;
pid_t mypid;
+string progid;
void dump(const string var){
char* str = getenv(var.c_str());
- cerr << progname
- << "[" << mypid << "] "
- << var;
+ cerr << progid << var;
if (str) cerr << " is set to '" << str << "'" << endl;
else cerr << " is not set." << endl;
}
@@ -276,8 +275,16 @@ int xclose(int arg){
extern char** environ;
int main(int argc, char** argv) {
- progname = *argv;
- mypid = getpid();
+ {
+ progname = *argv;
+ mypid = getpid();
+ string shortname = progname;
+ size_t where = shortname.rfind("/");
+ if (where != string::npos) shortname = shortname.substr(1+where);
+ stringstream binder;
+ binder << shortname << "[" << mypid << "]";
+ progid = binder.str();
+ }
#define foo(name, num) codemap[num] = #name ;
bar
@@ -649,14 +656,18 @@ bar
exword = foo.str();
}
}
- cerr << "hi-q concludes: kid[" << kidno << "]"
- << " pid " << argbest_blame
- << " i.e. '" << filter[kidno].cmd[0] << "'"
+ cerr << progid
+ << " concludes: kid[" << kidno << "]"
+ << " i.e. " << filter[kidno].cmd[0]
+ << "[" << argbest_blame << "]"
<< " reports " << exword << endl;
exeunt(excode);
} else if (WIFSIGNALED(best_blame)) {
int sig = WTERMSIG(best_blame);
- cerr << "hi-q says: kid " << argbest_blame
+ cerr << progid
+ << " concludes: kid[" << kidno << "]"
+ << " i.e. " << filter[kidno].cmd[0]
+ << "[" << argbest_blame << "]"
<< " was killed by signal " << sig
<< endl;
// if the *best* blame is a kill, that's not normal
@@ -677,14 +688,18 @@ bar
waitpid(special_pid, &kidstatus, WUNTRACED);
if (WIFEXITED(kidstatus)) {
int sts = WEXITSTATUS(kidstatus);
- cerr << "hi-q says: qq program " << kidpid[nkids-1]
- << " i.e. '" << filter[nkids-1].cmd[0] << "'"
+ cerr << progid
+ << " says: qq program"
+ << " i.e. " << filter[nkids-1].cmd[0]
+ << "[" << kidpid[nkids-1] << "]"
<< " returned status " << sts
<< endl;
return sts;
} else if (WIFSIGNALED(kidstatus)) {
- cerr << "hi-q says: qq program " << kidpid[nkids-1]
- << " i.e. '" << filter[nkids-1].cmd[0] << "'"
+ cerr << progid
+ << " says: qq program"
+ << " i.e. " << filter[nkids-1].cmd[0]
+ << "[" << kidpid[nkids-1] << "]"
<< " was killed by signal " << WTERMSIG(kidstatus)
<< endl;
return ex_syserr;