diff options
-rw-r--r-- | tools/hi-q.c | 15 | ||||
-rw-r--r-- | tools/hi-test.c | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/tools/hi-q.c b/tools/hi-q.c index 40d7100..9d85b7a 100644 --- a/tools/hi-q.c +++ b/tools/hi-q.c @@ -20,6 +20,7 @@ using namespace std; #include <sstream> #include <string> #include <vector> +#include <sstream> // error exit codes, as stated in qmail.c const int ex_spam = 21; @@ -126,7 +127,9 @@ int xclose(int arg){ return close(arg); } -int main(int argc, char** argv, char const * const * env) { +extern char** environ; + +int main(int argc, char** argv) { int verbose(1); int kidstatus; pid_t somekid; @@ -339,7 +342,15 @@ int main(int argc, char** argv, char const * const * env) { close(resync[rEnd]); close(sync[rEnd]); close(sync[wEnd]); - rslt = Execve(prog[0], prog, env); + + stringstream convert; + convert << getpgid(0); + const string grouper("HI_Q_GROUP=" + convert.str()); + if (putenv((char*)grouper.c_str()) != 0) { + cerr << "putenv failed" << endl; + exit(1); + } + rslt = Execve(prog[0], prog, environ); fprintf(stderr, "hi-q: failed to exec '%s': ", prog[0]); perror(0); exit(ex_syserr); diff --git a/tools/hi-test.c b/tools/hi-test.c index 3086535..d74b3c9 100644 --- a/tools/hi-test.c +++ b/tools/hi-test.c @@ -1,7 +1,11 @@ #include <iostream> +#include <stdlib.h> using namespace std; int main(){ - cerr << "++++ hi-test pid: " << getpid() << " group: " << getpgid(0) << endl; + cerr << "++++ hi-test pid: " << getpid() << " group: " << getpgid(0); + char* foo = getenv("HI_Q_GROUP"); + if (foo) cerr << " HI_Q_GROUP: " << foo; + cerr << endl; } |