Index: /trunk/Ohana/src/opihi/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/Makefile	(revision 3210)
+++ /trunk/Ohana/src/opihi/Makefile	(revision 3211)
@@ -12,4 +12,5 @@
 sched: lib.data lib.shell cmd.basic cmd.data cmd.astro
 pclient: lib.data lib.shell cmd.basic
+pcontrol: lib.data lib.shell cmd.basic
 
 LIBS = cmd.basic cmd.data cmd.astro lib.data lib.shell
@@ -17,5 +18,5 @@
 PROGRAM = mana dvo
 
-EXTRAS = dvo2 sched dimm pclient
+EXTRAS = dvo2 sched dimm pclient pcontrol
 
 all:
Index: /trunk/Ohana/src/opihi/include/pclient.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pclient.h	(revision 3210)
+++ /trunk/Ohana/src/opihi/include/pclient.h	(revision 3211)
@@ -74,2 +74,4 @@
 int CheckChild ();
 void CheckChildStatus ();
+
+# define DTIME(A,B) ((A.tv_sec - B.tv_sec) + 1e-6*(A.tv_usec - B.tv_usec))
Index: /trunk/Ohana/src/opihi/lib.shell/opihi.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 3211)
@@ -6,4 +6,5 @@
   int i, Nbad, Nlist, status;
   char **list, *line, *outline, *prompt, *history;
+  pid_t ppid;
 
   initialize (argc, argv);
@@ -19,4 +20,10 @@
     line = readline (prompt);
     if (line == NULL) { 
+      
+      ppid = getppid();
+      if (ppid == 1) {
+	fprintf (stderr, "caught parent shutdown\n");
+	exit (2);
+      }
       if (!isatty (STDIN_FILENO)) exit (2);
       fprintf (stdout, "Use \"quit\" to exit\n");
Index: /trunk/Ohana/src/opihi/pclient/ChildOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pclient/ChildOps.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pclient/ChildOps.c	(revision 3211)
@@ -1,3 +1,6 @@
 # include "pclient.h"
+
+static int Nbad = 0;
+static struct timeval last = {0, 0};
 
 int InitChild () {
@@ -22,4 +25,25 @@
 
   int Nread;
+  pid_t ppid;
+  double dtime;
+  struct timeval now;
+
+  /* this is really lame : check if we are calling too quickly */
+  gettimeofday (&now, NULL);
+  dtime = DTIME (now, last);
+  last = now;
+  if (dtime < 0.0001) Nbad ++;
+  if (dtime > 0.01) Nbad = 0;
+  if (Nbad > 10) {
+    fprintf (stderr, "parent shutdown\n");
+    exit (2);
+  }  
+
+  /* this is a bit lame : we must exit if calling process exits */
+  ppid = getppid();
+  if (ppid == 1) {
+    fprintf (stderr, "parent shutdown\n");
+    exit (2);
+  }  
 
   CheckChildStatus ();
Index: /trunk/Ohana/src/opihi/pclient/pclient.c
===================================================================
--- /trunk/Ohana/src/opihi/pclient/pclient.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pclient/pclient.c	(revision 3211)
@@ -13,4 +13,9 @@
   fprintf (stderr, "\n");
   fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
+}
+
+void gotsignal (int signum) {
+  fprintf (stderr, "got signal : %d\n", signum);
+  return;
 }
 
@@ -53,4 +58,7 @@
   /* ignore the history file.  to change this, see, eg, mana.c */
   signal (SIGINT, SIG_IGN);
+  signal (SIGPIPE, gotsignal);
+  signal (SIGTSTP, gotsignal);
+  signal (SIGTTIN, gotsignal);
   return;
 }
Index: /trunk/Ohana/src/opihi/pcontrol/CheckHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckHost.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckHost.c	(revision 3211)
@@ -39,5 +39,5 @@
 
     default:
-      fprintf (stderr, "host %s is alive\n", host[0].hostname);
+      /* fprintf (stderr, "host %s is alive\n", host[0].hostname); */
       PutHost (host, host[0].stack, STACK_BOTTOM);
       FreeIOBuffer (&buffer);
Index: /trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c	(revision 3211)
@@ -13,4 +13,5 @@
     job = (Job *) stack[0].object[i];
     if (job[0].mode != PCONTROL_JOB_NEEDHOST) continue;
+    if (job[0].hostname == NULL) continue;
     if (strcasecmp (job[0].hostname, host[0].hostname)) continue;
     LinkJobAndHost (job, host);
@@ -23,4 +24,5 @@
     job = (Job *) stack[0].object[i];
     if (job[0].mode != PCONTROL_JOB_WANTHOST) continue;
+    if (job[0].hostname == NULL) continue;
     if (strcasecmp (job[0].hostname, host[0].hostname)) continue;
     LinkJobAndHost (job, host);
@@ -33,5 +35,4 @@
     job = (Job *) stack[0].object[i];
     if (job[0].mode != PCONTROL_JOB_ANYHOST) continue;
-    if (strcasecmp (job[0].hostname, host[0].hostname)) continue;
     LinkJobAndHost (job, host);
     StartJob (job);
Index: /trunk/Ohana/src/opihi/pcontrol/StartHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StartHost.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pcontrol/StartHost.c	(revision 3211)
@@ -9,6 +9,6 @@
   /* pid = rconnect (CONNECT, host[0].hostname, PCLIENT, stdio); */
 
-  strcpy (command, "ssh");
-  strcpy (shell, "pclient");
+  if (VarConfig ("COMMAND", "%s", command) == NULL) strcpy (command, "ssh");
+  if (VarConfig ("SHELL", "%s", shell)     == NULL) strcpy (shell, "pclient");
 
   pid = rconnect (command, host[0].hostname, shell, stdio);
Index: /trunk/Ohana/src/opihi/pcontrol/pclient.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/pclient.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pcontrol/pclient.c	(revision 3211)
@@ -9,6 +9,7 @@
   int status;
   char *line;
-  
+
   /* send command to client (adding on \n) */
+  fprintf (stderr, "send: %s (%d)\n", command, buffer[0].Nbuffer);
   ALLOCATE (line, char, MAX (1, strlen(command)));
   sprintf (line, "%s\n", command);
@@ -28,4 +29,5 @@
   if (status ==  0) return (PCLIENT_DOWN);
   if (status == -1) return (PCLIENT_HUNG);
+  fprintf (stderr, "buffer.buffer: %s\n", buffer[0].buffer);
   return (PCLIENT_GOOD);
 }
Index: /trunk/Ohana/src/opihi/pcontrol/rconnect.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/rconnect.c	(revision 3210)
+++ /trunk/Ohana/src/opihi/pcontrol/rconnect.c	(revision 3211)
@@ -27,4 +27,5 @@
   argv[2] = shell;
   argv[3] = 0;
+  fprintf (stderr, "%s %s %s\n", argv[0], argv[1], argv[2]);
 
   pid = fork ();
