Index: trunk/Ohana/src/opihi/pantasks/CheckController.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/CheckController.c	(revision 4748)
+++ trunk/Ohana/src/opihi/pantasks/CheckController.c	(revision 4762)
@@ -3,8 +3,12 @@
 int CheckController () {
 
+  float dtime;
+  struct timeval start, stop;
   char *p, *q;
   int i, Njobs, status, JobID;
   Job *job;
   IOBuffer buffer;
+
+  gettimeofday (&start, (void *) NULL);
 
   /* get the list of completed jobs (exit / crash), update the job status */
@@ -32,6 +36,11 @@
   }
 
+  gettimeofday (&stop, (void *) NULL);
+  dtime = DTIME (stop, start);
+  if (VerboseMode()) fprintf (stderr, "check stack %f\n", dtime);
+  gettimeofday (&start, (void *) NULL);
+
   p = buffer.buffer;
-  for (i = 0; i < Njobs; i++) {
+  for (i = 0; (i < Njobs) && !TestElapsedCheck(); i++) {
     q = strchr (p, '\n');
     if (q == NULL) {
@@ -50,5 +59,10 @@
     CheckControllerJob (job);
   }
- 
+  gettimeofday (&stop, (void *) NULL);
+  dtime = DTIME (stop, start);
+  if (VerboseMode()) fprintf (stderr, "check %d jobs %f\n", i, dtime);
+
+  if (TestElapsedCheck()) return (TRUE);
+
   /*** check CRASH jobs ***/
   FlushIOBuffer (&buffer);
@@ -72,5 +86,5 @@
 
   p = buffer.buffer;
-  for (i = 0; i < Njobs; i++) {
+  for (i = 0; (i < Njobs) && !TestElapsedCheck(); i++) {
     q = strchr (p, '\n');
     if (q == NULL) {
Index: trunk/Ohana/src/opihi/pantasks/CheckJobs.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/CheckJobs.c	(revision 4748)
+++ trunk/Ohana/src/opihi/pantasks/CheckJobs.c	(revision 4762)
@@ -83,4 +83,5 @@
     /* reset polling clock */
     SetTaskTimer (&job[0].last);
+    if (TestElapsedCheck()) return (TRUE);
   }
   return (TRUE);
Index: trunk/Ohana/src/opihi/pantasks/CheckSystem.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 4748)
+++ trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 4762)
@@ -1,38 +1,36 @@
 # include "psched.h"
+
+# define MAX_DELAY 0.1
+struct timeval start;
+static int Ncheck = 0;
 
 int CheckSystem () {
 
-  /* need to make a timeout: if this process lasts too long, 
-     we should return so the user can get input in.  this cannot
-     just be a return, because we need to hit each of the elements
-     eventually
-  */
-  struct timeval start, stop;
-  double dtime;
-  
   gettimeofday (&start, (void *) NULL);
-  CheckTasks ();
+
+  if (Ncheck < 5) {
+    CheckTasks ();
+    CheckJobs ();
+    Ncheck ++;
+  } else {
+    CheckController ();
+    CheckControllerOutput ();
+    Ncheck = 0;
+  }
+  return (TRUE);
+}
+
+int TestElapsedCheck () {
+
+  struct timeval stop;
+  float dtime;
+
   gettimeofday (&stop, (void *) NULL);
   dtime = DTIME (stop, start);
-  if (VerboseMode()) fprintf (stderr, "check 1: %f seconds\n", dtime);
+  if (dtime > MAX_DELAY) return (TRUE);
+  return (FALSE);
+}
 
-  gettimeofday (&start, (void *) NULL);
-  CheckJobs ();
-  gettimeofday (&stop, (void *) NULL);
-  dtime = DTIME (stop, start);
-  if (VerboseMode()) fprintf (stderr, "check 2: %f seconds\n", dtime);
-
-  gettimeofday (&start, (void *) NULL);
-  CheckController ();
-  gettimeofday (&stop, (void *) NULL);
-  dtime = DTIME (stop, start);
-  if (VerboseMode()) fprintf (stderr, "check 3: %f seconds\n", dtime);
-
-  gettimeofday (&start, (void *) NULL);
-  CheckControllerOutput ();
-  gettimeofday (&stop, (void *) NULL);
-  dtime = DTIME (stop, start);
-  if (VerboseMode()) fprintf (stderr, "check 4: %f seconds\n", dtime);
-
-  return (TRUE);
-}
+  /* do we really need to check the controller on every call?
+     or perhaps alternate?
+  */
Index: trunk/Ohana/src/opihi/pantasks/CheckTasks.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/CheckTasks.c	(revision 4748)
+++ trunk/Ohana/src/opihi/pantasks/CheckTasks.c	(revision 4762)
@@ -33,4 +33,6 @@
     gettimeofday (&task[0].last, (void *) NULL);
     task[0].Njobs ++;
+
+    if (TestElapsedCheck()) return (TRUE);
   }
   return (TRUE);
Index: trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4748)
+++ trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4762)
@@ -1,5 +1,5 @@
 # include "psched.h"
 /* adding a new host can delay controller up to a second or so */
-# define CONTROLLER_TIMEOUT 200
+# define CONTROLLER_TIMEOUT 500
 # define CONNECT_TIMEOUT 300
 
@@ -18,9 +18,20 @@
 /* check job / get output if done */
 int CheckControllerJob (Job *job) {
-
+  struct timeval start, stop;
+  float dtime;
+
+  gettimeofday (&start, (void *) NULL);
   CheckControllerJobStatus (job);
+  gettimeofday (&stop, (void *) NULL);
+  dtime = DTIME (stop, start);
+  if (VerboseMode()) fprintf (stderr, "check job status %f\n", dtime);
 
   if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
+    gettimeofday (&start, (void *) NULL);
     GetJobOutput ("stdout", job[0].pid, &job[0].stdout, job[0].stdout_size);
+    gettimeofday (&stop, (void *) NULL);
+    dtime = DTIME (stop, start);
+    if (VerboseMode()) fprintf (stderr, "get stdout %f\n", dtime);
+
     GetJobOutput ("stderr", job[0].pid, &job[0].stderr, job[0].stderr_size);
     DeleteControllerJob (job);
@@ -97,4 +108,9 @@
   int i, status, Nstart;
   char *line;
+  struct timespec request, remain;
+
+  /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */
+  request.tv_sec = 0;
+  request.tv_nsec = 100000;
 
   /* flush any earlier messages */
@@ -117,5 +133,5 @@
       line = memstr (buffer[0].buffer, CONTROLLER_PROMPT, buffer[0].Nbuffer);
     }
-    if (status == -1) usleep (10000);
+    if (status == -1) nanosleep (&request, &remain);
   }
   if (status ==  0) return (CONTROLLER_DOWN);
@@ -256,4 +272,5 @@
 
   /* try to get evidence connection is alive - wait upto a few seconds */
+  /* connection is likely slow; don't bother with nanosleep here */
   p = NULL;
   status = -1;
@@ -300,7 +317,11 @@
 int ControllerCommand (char *cmd, char *response, IOBuffer *buffer) {
 
-  int i;
-  int status;
+  int i, status;
   char *line;
+  struct timespec request, remain;
+
+  /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */
+  request.tv_sec = 0;
+  request.tv_nsec = 100000;
 
   ReadtoIOBuffer (buffer, stdout_cntl);
@@ -323,5 +344,5 @@
     status = ReadtoIOBuffer (buffer, stdout_cntl);
     line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
-    if (status == -1) usleep (10000);
+    if (status == -1) nanosleep (&request, &remain);
   }
   if (status ==  0) {
@@ -341,5 +362,5 @@
     bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
   }
-  if (VerboseMode()) fprintf (stderr, "message received\n");
+  if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i);
   return (TRUE);
 }
Index: trunk/Ohana/src/opihi/pantasks/controller_output.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/controller_output.c	(revision 4748)
+++ trunk/Ohana/src/opihi/pantasks/controller_output.c	(revision 4762)
@@ -8,4 +8,5 @@
   }
 
+  CheckControllerOutput ();
   PrintControllerOutput ();
   return (TRUE);
