Index: trunk/Ohana/src/opihi/pclient/ChildOps.c
===================================================================
--- trunk/Ohana/src/opihi/pclient/ChildOps.c	(revision 4762)
+++ trunk/Ohana/src/opihi/pclient/ChildOps.c	(revision 4763)
@@ -1,3 +1,7 @@
 # include "pclient.h"
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stropts.h>
 
 static int Nbad = 0;
@@ -29,18 +33,21 @@
   struct timeval now;
 
-  /* this is really lame : check if we are calling too quickly 
-     this is unneeded: pclient.c rl_keyboard_input_timeout limits
-     the rate 
-  gettimeofday (&now, NULL);
-  dtime = DTIME (now, last);
+  /* runaway test - if pcontrol is killed, pclient starts running away.  this test is a bit
+     dangerous: the choice of dtime probably depends on the processor and the value provided to
+     pclient.c:rl_set_keyboard_input_timeout (1000); note that we cannot use getppid == 1 as a test
+     because the parent of pclient is the ssh process on the pclient host, not pcontrol.  in any
+     case, the opihi shell catches if the ssh dies using getppid
+   */
+  gettimeofday (&now, (void *) NULL);
+  dtime = 1e6*DTIME (now, last);
+  if (dtime < 100) {
+    Nbad ++;
+    if (Nbad > 10) {
+      fprintf (stderr, "runaway!\n");
+      exit (2);
+    }
+  }
+  if (dtime > 950) Nbad = 0;
   last = now;
-  if (dtime < 0.0001) Nbad ++;
-  if (dtime > 0.01) Nbad = 0;
-  if (Nbad > 10) exit (2);
-  */
-
-  /* this is a bit lame : we must exit if calling process exits */
-  ppid = getppid();
-  if (ppid == 1) exit (2);
 
   CheckChildStatus ();
