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 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tools/hi-q.c') 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 -- cgit v1.2.3