Index: /trunk/Ohana/src/opihi/cmd.basic/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 4714)
@@ -76,7 +76,15 @@
   int i;
 
+  InitCommands ();
+  InitMacros ();
+  InitBuffers ();
+  InitVectors ();
+  InitVariables ();
+  InitLists ();
+  InitOutfile ();
+
   for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) {
     AddCommand (&cmds[i]);
   }
-
+  
 }
Index: /trunk/Ohana/src/opihi/cmd.data/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/init.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/cmd.data/init.c	(revision 4714)
@@ -215,4 +215,8 @@
   int i;
 
+  InitGraph ();
+  InitImage ();
+  InitQueues ();
+
   for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) {
     AddCommand (&cmds[i]);
Index: /trunk/Ohana/src/opihi/dimm/dimm.c
===================================================================
--- /trunk/Ohana/src/opihi/dimm/dimm.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/dimm/dimm.c	(revision 4714)
@@ -12,23 +12,7 @@
   auto_break = TRUE;
 
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libopihi */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdisplay */
-  InitGraph ();
-  InitImage ();
-
   /* load the commands used by this implementation */
   InitBasic ();
   InitData ();
-  InitOutfile ();
   InitAstro ();
   InitDIMM ();
Index: /trunk/Ohana/src/opihi/dvo/dvo.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo/dvo.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/dvo/dvo.c	(revision 4714)
@@ -12,23 +12,7 @@
   auto_break = TRUE;
 
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libopihi */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdisplay */
-  InitGraph ();
-  InitImage ();
-
   /* load the commands used by this implementation */
   InitBasic ();
   InitData ();
-  InitOutfile ();
   InitAstro ();
   InitDVO ();
Index: /trunk/Ohana/src/opihi/dvo2/dvo2.c
===================================================================
--- /trunk/Ohana/src/opihi/dvo2/dvo2.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/dvo2/dvo2.c	(revision 4714)
@@ -7,35 +7,8 @@
 # define opihi_rcfile ".dvorc"
 
-void InitBasic ();
-void InitData ();
-void InitAstro ();
-void InitDVO2 ();
-
-void welcome () {
-  fprintf (stderr, "\n");
-  fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
-}
-
 /* program-dependent initialization */
 void initialize (int argc, char **argv) {
   
-  FILE *f;
-
   auto_break = TRUE;
-
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libopihi */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdisplay */
-  InitGraph ();
-  InitImage ();
 
   /* load the commands used by this implementation */
@@ -44,5 +17,4 @@
   InitAstro ();
   InitDVO2 ();
-  InitOutfile ();
 
   rl_readline_name = opihi_name;
@@ -52,19 +24,18 @@
   set_str_variable ("PROMPT", opihi_prompt);
   set_str_variable ("RCFILE", opihi_rcfile);
+# ifdef HELPDIR_DEFAULT
+  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# endif
 
-  /* here we open the history file for append.  it this fails, we
-     won't be able to write to it, warn the user.  otherwise, this
-     creates the file readline will write to, if it did not exist */  
-
-  /* check history file */
-  /* rewrite with fstat or stat */
-  f = fopen (opihi_history, "a");
-  if (f == NULL) /* no current history file here */
-    fprintf (stderr, "can't save history.\n");
-  else
-    fclose (f);
-  
-  stifle_history (200);
-  read_history (opihi_history);
+  { /* check history file permission */
+    FILE *f;
+    f = fopen (opihi_history, "a");
+    if (f == NULL) /* no current history file here */
+      fprintf (stderr, "can't save history.\n");
+    else
+      fclose (f);
+    stifle_history (200);
+    read_history (opihi_history);
+  }
 
   signal (SIGINT, SIG_IGN);
@@ -72,9 +43,15 @@
 }
 
+/* standard welcome message */
+void welcome () {
+  fprintf (stderr, "\n");
+  fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
+}
+
 /* add program-dependent exit functions here */
 void cleanup () {
-  /* -libdisplay
+  /* -libdisplay */
   QuitImage ();
-  QuitGraph (); */
+  QuitGraph ();
   return;
 }
Index: /trunk/Ohana/src/opihi/include/psched.h
===================================================================
--- /trunk/Ohana/src/opihi/include/psched.h	(revision 4713)
+++ /trunk/Ohana/src/opihi/include/psched.h	(revision 4714)
@@ -151,4 +151,5 @@
 int CheckTasks ();
 int CheckSystem ();
+int CheckController ();
 int CheckTimeRanges (TimeRange *ranges, int Nranges);
 int GetJobOutput (char *channel, int pid, IOBuffer *buffer, int Nbytes);
@@ -156,4 +157,6 @@
 int CheckControllerJobStatus (Job *job);
 int SubmitControllerJob (Job *job);
+int DeleteControllerJob (Job *job);
+Job *FindControllerJob (int JobID);
 int StartController ();
 int ControllerCommand (char *command, char *response, IOBuffer *buffer);
Index: /trunk/Ohana/src/opihi/include/shell.h
===================================================================
--- /trunk/Ohana/src/opihi/include/shell.h	(revision 4713)
+++ /trunk/Ohana/src/opihi/include/shell.h	(revision 4714)
@@ -59,4 +59,5 @@
 int           is_loop               	PROTO((char *line));
 int           is_macro_create       	PROTO((char *line));
+void          InitLists                 PROTO(());
 
 void          InitCommands              PROTO(());
Index: /trunk/Ohana/src/opihi/lib.shell/ListOps.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/ListOps.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/lib.shell/ListOps.c	(revision 4714)
@@ -1,4 +1,10 @@
 # include "opihi.h"
 # include "macro.h"
+
+void InitLists () {
+  Nlists = 0;
+  ALLOCATE (lists, List, 1); 
+  return;
+}
 
 /* return a new string consisting of the next line in the current list */
Index: /trunk/Ohana/src/opihi/mana/mana.c
===================================================================
--- /trunk/Ohana/src/opihi/mana/mana.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/mana/mana.c	(revision 4714)
@@ -12,23 +12,7 @@
   auto_break = TRUE;
 
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libopihi */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdisplay */
-  InitGraph ();
-  InitImage ();
-
   /* load the commands used by this implementation */
   InitBasic ();
   InitData ();
-  InitOutfile ();
   InitAstro ();
   InitMana ();
Index: /trunk/Ohana/src/opihi/pantasks/CheckController.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckController.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/CheckController.c	(revision 4714)
@@ -7,8 +7,6 @@
   Job *job;
   IOBuffer buffer;
-  
 
   /* get the list of completed jobs (exit / crash), update the job status */
-
   if (!CheckControllerStatus()) return (TRUE);
 
@@ -21,20 +19,30 @@
   }
 
+  p = memstr (buffer.buffer, "USAGE: jobstack", buffer.Nbuffer);
+  if (p != NULL) {
+    FreeIOBuffer (&buffer);
+    return (FALSE);
+  }
+
   /** parse job list **/
-  sscanf (buffer.buffer, "%*s %s", &Njobs);
+  status = sscanf (buffer.buffer, "%*s %d", &Njobs);
+  if (status != 1) {
+    FreeIOBuffer (&buffer);
+    return (FALSE);
+  }
+
   p = buffer.buffer;
-  
   for (i = 0; i < Njobs; i++) {
     q = strchr (p, '\n');
     if (q == NULL) {
       fprintf (stderr, "controller message error: incomplete job list\n");
-      FreeIOBuffer (&buffer);
       break;
     }
-    p = q++;
-    sscanf (p, "%d", &JobID);
-    job = FindJob (JobID);
+    p = q + 1;
+    status = sscanf (p, "%d", &JobID);
+
+    job = FindControllerJob (JobID);
     if (job == NULL) {
-      fprintf (stderr, "misplaced job? %d not in job list\n");
+      fprintf (stderr, "misplaced job? %d not in EXIT job list\n", JobID);
       continue;
     }
@@ -42,7 +50,7 @@
     CheckControllerJob (job);
   }
-    
+ 
   /*** check CRASH jobs ***/
-  InitIOBuffer (&buffer, 0x100);
+  FlushIOBuffer (&buffer);
   status = ControllerCommand ("jobstack crash", CONTROLLER_PROMPT, &buffer);
   if (!status) {
@@ -50,21 +58,30 @@
     return (FALSE);
   }
+  p = memstr (buffer.buffer, "USAGE: jobstack", buffer.Nbuffer);
+  if (p != NULL) {
+    FreeIOBuffer (&buffer);
+    return (FALSE);
+  }
 
   /** parse job list **/
-  sscanf (buffer.buffer, "%*s %s", &Njobs);
+  status = sscanf (buffer.buffer, "%*s %d", &Njobs);
+  if (status != 1) {
+    FreeIOBuffer (&buffer);
+    return (FALSE);
+  }
+
   p = buffer.buffer;
-  
   for (i = 0; i < Njobs; i++) {
     q = strchr (p, '\n');
     if (q == NULL) {
       fprintf (stderr, "controller message error: incomplete job list\n");
-      FreeIOBuffer (&buffer);
       break;
     }
-    p = q++;
-    sscanf (p, "%d", &JobID);
-    job = FindJob (JobID);
+    p = q + 1;
+    
+    status = sscanf (p, "%d", &JobID);
+    job = FindControllerJob (JobID);
     if (job == NULL) {
-      fprintf (stderr, "misplaced job? %d not in job list\n");
+      fprintf (stderr, "misplaced job? %d not in CRASH job list\n", JobID);
       continue;
     }
@@ -72,4 +89,5 @@
     CheckControllerJob (job);
   }
+  FreeIOBuffer (&buffer);
   return (TRUE);
 }
Index: /trunk/Ohana/src/opihi/pantasks/CheckSystem.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 4714)
@@ -8,9 +8,31 @@
      eventually
   */
+  struct timeval start, stop;
+  double dtime;
+  
+  gettimeofday (&start, (void *) NULL);
+  CheckTasks ();
+  gettimeofday (&stop, (void *) NULL);
+  dtime = DTIME (stop, start);
+  if (VerboseMode()) fprintf (stderr, "check 1: %f seconds\n", dtime);
 
-  CheckTasks ();
+  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);
 }
Index: /trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4714)
@@ -186,7 +186,4 @@
   job[0].pid = atoi (string);
   FreeIOBuffer (&buffer);
-
-  InitIOBuffer (&job[0].stdout, 0x100);
-  InitIOBuffer (&job[0].stderr, 0x100);
   return (TRUE);
 }
@@ -419,4 +416,6 @@
   InitIOBuffer (&buffer, 0x100);
   status = ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
+  FreeIOBuffer (&buffer);
+
   ControllerStatus = FALSE;
   result = waitpid (ControllerPID, &waitstatus, WNOHANG);
@@ -429,5 +428,7 @@
   close (stdout_cntl);
   close (stderr_cntl);
-
-  return (TRUE);
-}
+  FreeIOBuffer (&stdout_buffer);
+  FreeIOBuffer (&stderr_buffer);
+
+  return (TRUE);
+}
Index: /trunk/Ohana/src/opihi/pantasks/JobOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 4714)
@@ -39,4 +39,19 @@
   for (i = 0; i < Njobs; i++) {
     if (jobs[i][0].JobID == JobID) {
+      return (jobs[i]);
+    }
+  }
+  return (NULL);
+}  
+
+/* return job with given controller Job ID */
+Job *FindControllerJob (int JobID) {
+
+  int i;
+
+  /* return job with matching JobID */
+  for (i = 0; i < Njobs; i++) {
+    if (jobs[i][0].mode == JOB_LOCAL) continue;
+    if (jobs[i][0].pid  == JobID) {
       return (jobs[i]);
     }
@@ -96,4 +111,7 @@
      need to have matched entries to these quantites in the job structure */
 
+  InitIOBuffer (&job[0].stdout, 0x100);
+  InitIOBuffer (&job[0].stderr, 0x100);
+
   jobs[Njobs] = job;
   Njobs ++;
@@ -117,4 +135,8 @@
   }
   free (job[0].argv);
+
+  FreeIOBuffer (&job[0].stdout);
+  FreeIOBuffer (&job[0].stderr);
+  free (job);
   return;
 }
@@ -161,5 +183,5 @@
   gettimeofday (&job[0].start, (void *) NULL);
   job[0].last = job[0].start;
-  
+  job[0].state = JOB_PENDING;
   return (TRUE);
 }
Index: /trunk/Ohana/src/opihi/pantasks/LocalJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 4714)
@@ -144,6 +144,4 @@
   job[0].pid = pid;
 
-  InitIOBuffer (&job[0].stdout, 0x100);
-  InitIOBuffer (&job[0].stderr, 0x100);
   return (TRUE);
 
Index: /trunk/Ohana/src/opihi/pantasks/controller_host.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 4714)
@@ -20,4 +20,4 @@
   if (status) fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
   FreeIOBuffer (&buffer);
-
+  return (TRUE);
 }
Index: /trunk/Ohana/src/opihi/pantasks/init.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/init.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/init.c	(revision 4714)
@@ -53,4 +53,8 @@
   int i;
 
+  InitTasks ();
+  InitJobs ();
+  InitJobIDs ();
+
   for (i = 0; i < sizeof (cmds) / sizeof (Command); i++) {
     AddCommand (&cmds[i]);
Index: /trunk/Ohana/src/opihi/pantasks/psched.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/psched.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pantasks/psched.c	(revision 4714)
@@ -12,27 +12,8 @@
   auto_break = TRUE;
 
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libopihi */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdisplay */
-  InitGraph ();
-  InitImage ();
-
   /* load the commands used by this implementation */
   InitBasic ();
   InitData ();
-  InitOutfile ();
   InitPsched ();
-  InitTasks ();
-  InitJobs ();
-  InitJobIDs ();
 
   rl_readline_name = opihi_name;
Index: /trunk/Ohana/src/opihi/pclient/pclient.c
===================================================================
--- /trunk/Ohana/src/opihi/pclient/pclient.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pclient/pclient.c	(revision 4714)
@@ -12,22 +12,6 @@
   auto_break = TRUE;
 
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libshell */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdata */
-  InitGraph ();
-  InitImage ();
-
   /* load the commands used by this implementation */
   InitBasic ();
-  InitOutfile ();
   InitPclient ();
   InitChild ();
Index: /trunk/Ohana/src/opihi/pcontrol/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/Makefile	(revision 4713)
+++ /trunk/Ohana/src/opihi/pcontrol/Makefile	(revision 4714)
@@ -54,4 +54,5 @@
 $(SDIR)/jobstack.$(ARCH).o \
 $(SDIR)/kill.$(ARCH).o \
+$(SDIR)/pulse.$(ARCH).o \
 $(SDIR)/status.$(ARCH).o \
 $(SDIR)/stdout.$(ARCH).o \
Index: /trunk/Ohana/src/opihi/pcontrol/init.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/init.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pcontrol/init.c	(revision 4714)
@@ -7,4 +7,5 @@
 int jobstack    PROTO((int, char **));
 int kill_pc     PROTO((int, char **));
+int pulse       PROTO((int, char **));
 int status      PROTO((int, char **));
 int stderr_pc   PROTO((int, char **));
@@ -19,4 +20,5 @@
   {"jobstack",  jobstack,  "list jobs for a single stack"},
   {"kill",      kill_pc,   "kill job"},
+  {"pulse",     pulse,     "set system pulse"},
   {"status",    status,    "get system status"},
   {"stderr",    stderr_pc, "get stderr buffer for job"},
Index: /trunk/Ohana/src/opihi/pcontrol/jobstack.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/jobstack.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pcontrol/jobstack.c	(revision 4714)
@@ -6,8 +6,6 @@
   Stack *stack;
   Job *job;
-  Host *host;
-  int JobID, HostID;
 
-  if (argc != 3) {
+  if (argc != 2) {
     fprintf (stdout, "USAGE: jobstack (jobstack)\n");
     fprintf (stdout, "       (jobstack) : pending, busy, exit, crash, hung, done\n");
@@ -27,5 +25,5 @@
     job = stack[0].object[i];
     /* PrintID (stdout, job[0].JobID); */
-    fprintf (stdout, "%d ", job[0].JobID);
+    fprintf (stdout, "%lld ", job[0].JobID);
     fprintf (stdout, "%s  %s\n", job[0].argv[0], job[0].hostname);
   }
Index: /trunk/Ohana/src/opihi/pcontrol/pcontrol.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/pcontrol.c	(revision 4713)
+++ /trunk/Ohana/src/opihi/pcontrol/pcontrol.c	(revision 4714)
@@ -12,22 +12,6 @@
   auto_break = TRUE;
 
-  Nlists = 0;
-  ALLOCATE (lists, List, 1); 
-
-  /* init functions required by libraries */
-  /* -libshell */
-  InitCommands ();
-  InitMacros ();
-  InitBuffers ();
-  InitVectors ();
-  InitVariables ();
-
-  /* -libdata */
-  InitGraph ();
-  InitImage ();
-
   /* load the commands used by this implementation */
   InitBasic ();
-  InitOutfile ();
   InitPcontrol ();
 
Index: /trunk/Ohana/src/opihi/scripts/psched.pro
===================================================================
--- /trunk/Ohana/src/opihi/scripts/psched.pro	(revision 4713)
+++ /trunk/Ohana/src/opihi/scripts/psched.pro	(revision 4714)
@@ -7,8 +7,8 @@
 task test
   command partest
-  periods -poll 1.0
-  periods -exec 2.0
+  periods -poll 0.1
+  periods -exec 0.1
   periods -timeout 10.0
-  nmax 15
+  nmax 5
   host anyhost
 
@@ -16,9 +16,12 @@
   task.exit 0
     # echo "task exit 0"
-    queuesize stdout -var Nstdout
-    for i 0 $Nstdout
-      queuepop stdout -var line
-      queuepush results "$line"
-    end
+    queuedelete stdout
+    queuedelete stderr
+    memory leaks
+#   queuesize stdout -var Nstdout
+#    for i 0 $Nstdout
+#      queuepop stdout -var line
+#      queuepush results "$line"
+#    end
   end
 
Index: /trunk/Ohana/src/opihi/scripts/sched.pro
===================================================================
--- /trunk/Ohana/src/opihi/scripts/sched.pro	(revision 4713)
+++ /trunk/Ohana/src/opihi/scripts/sched.pro	(revision 4714)
@@ -1,4 +1,2 @@
-
-# controller host alala
 
 task test
@@ -9,5 +7,5 @@
   # trange 07:09 07:10
   # trange -exclude 07:09:30 07:09:45
-  nmax 1
+  nmax 5
   host local
   # host localhost
@@ -20,7 +18,10 @@
   # stdout / stderr lines on named queues
   task.exit 0
-    echo "task exit 0"
-    queuesize stdout
-    queuesize stderr
+#    echo "task exit 0"
+#    queuesize stdout
+#    queuesize stderr
+    queuedelete stdout
+    queuedelete stderr
+    memory leaks
   end
 
