Index: /branches/eam_branches/20091201/Ohana/src/opihi/include/pclient.h
===================================================================
--- /branches/eam_branches/20091201/Ohana/src/opihi/include/pclient.h	(revision 26781)
+++ /branches/eam_branches/20091201/Ohana/src/opihi/include/pclient.h	(revision 26782)
@@ -52,4 +52,6 @@
 void FreePclient (void);
 void gotsignal (int signum);
+void pipe_signal (int signum);
+void pipe_signal_clear(void);
 
 # define DTIME(A,B) ((A.tv_sec - B.tv_sec) + 1e-6*(A.tv_usec - B.tv_usec))
Index: /branches/eam_branches/20091201/Ohana/src/opihi/pclient/ChildOps.c
===================================================================
--- /branches/eam_branches/20091201/Ohana/src/opihi/pclient/ChildOps.c	(revision 26781)
+++ /branches/eam_branches/20091201/Ohana/src/opihi/pclient/ChildOps.c	(revision 26782)
@@ -1,6 +1,6 @@
 # include "pclient.h"
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <unistd.h>
+# include <sys/ioctl.h>
+# include <sys/types.h>
+# include <unistd.h>
 // #include <stropts.h>
 
@@ -67,4 +67,5 @@
     case 0:   /* pipe is closed */
       /** change child state? **/
+      pipe_signal_clear();
       break;
     default:  /* data in pipe */
@@ -81,4 +82,5 @@
     case 0:   /* pipe is closed */
       /** change child state? **/
+      pipe_signal_clear();
       break;
     default:  /* data in pipe */
Index: /branches/eam_branches/20091201/Ohana/src/opihi/pclient/pclient.c.in
===================================================================
--- /branches/eam_branches/20091201/Ohana/src/opihi/pclient/pclient.c.in	(revision 26781)
+++ /branches/eam_branches/20091201/Ohana/src/opihi/pclient/pclient.c.in	(revision 26782)
@@ -46,5 +46,15 @@
 
   /* ignore the history file.  to change this, see, eg, mana.c */
-  signal (SIGPIPE, gotsignal);
+
+  /* We do not want pclient to exit just because the connection to the 
+     child process is broken.  However, if the connection to the parent 
+     process is broken, we should exit.  To handle this, we define 
+     pipe_signal() which tracks the number of times it has been called.
+     Every time an I/O operation on the child file descriptor raises this signal, 
+     we need to manage the crashed child and then clear the count.  Signals raised by 
+     I/O to the parent do not result in clearing the count.  If the count passes a maximum,
+     we exit pclient */
+     
+  signal (SIGPIPE, pipe_signal);
   signal (SIGTSTP, gotsignal);
   signal (SIGTTIN, gotsignal);
@@ -67,4 +77,19 @@
 }
 
+static int Npipe = 0;
+
+void pipe_signal (int signum) {
+  Npipe ++;
+  if (Npipe > 100) {
+    exit (5);
+  }
+  gprint (GP_ERR, "closed pipe : did child process exit unexpectedly?\n");
+  return;
+}
+
+void pipe_signal_clear(void) {
+  Npipe = 0;
+}
+
 void gotsignal (int signum) {
   gprint (GP_ERR, "got signal : %d\n", signum);
