From 4b48aa187bd7917842ec651dbd0322396b363c2f Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 15 Jul 2012 00:43:51 -0700 Subject: annoying race condition, works sometimes but not reliable --- tools/hi-q.c | 7 ++++--- tools/hi-test.c | 2 +- tools/hi-test.conf | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/hi-q.c b/tools/hi-q.c index 14ca5ec..1e71ef4 100644 --- a/tools/hi-q.c +++ b/tools/hi-q.c @@ -217,7 +217,7 @@ int main(int argc, char** argv, char const * const * env) { // doesn't choose it. That allows N-1 of the kids // to close it and dup() something useful onto it. - for (unsigned int ii=0; ii < nkids; ii++){ /* loop over all kids */ + for (unsigned int ii=0; ii < nkids; ii++){ /* loop starting all kids */ int datapipe[2]; int kid_end; @@ -307,13 +307,14 @@ int main(int argc, char** argv, char const * const * env) { // it is important to let kid#0 run a while; // otherwise it won't fully exist when the other kids start, // and depending race conditions, the setpgid could fail - if (1) usleep(0); +////////??? if (1) usleep(0); + if (ii == 0) usleep(1); #if 1 cerr << "forked kid #" << ii << " (" << kidpid[ii] << ") " << endl; #endif - } + } /* end loop starting all kids */ // here with the whole pipeline of kids running diff --git a/tools/hi-test.c b/tools/hi-test.c index 3befedd..01e475b 100644 --- a/tools/hi-test.c +++ b/tools/hi-test.c @@ -3,5 +3,5 @@ using namespace std; int main(){ - cerr << getpid() << " : " << getpgid(0) << endl; + cerr << "++++ " << getpid() << " : " << getpgid(0) << endl; } diff --git a/tools/hi-test.conf b/tools/hi-test.conf index d09ba81..6c697c2 100644 --- a/tools/hi-test.conf +++ b/tools/hi-test.conf @@ -1,3 +1,3 @@ -hi-test -hi-test -hi-test +hi-test x0 +hi-test x1 +hi-test x2 -- cgit v1.2.3