Index: trunk/Ohana/src/opihi/pantasks/LocalJob.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 4691)
+++ trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 4693)
@@ -1,3 +1,3 @@
-# include "scheduler.h"
+# include "psched.h"
 
 /* this could be written a just a one-way pipe */
@@ -66,32 +66,31 @@
   CheckLocalJobStatus (job);
 
-  /* read stdout buffer */
-  Nread = ReadtoIOBuffer (&job[0].stdout, job[0].stdout_fd);
-  switch (Nread) {
-    case -2:  /* error in read (programming error?  system level error?) */
-      fprintf (stderr, "serious IO error\n");
-      exit (2);
-    case -1:  /* no data in pipe */
-      break;
-    case 0:   /* pipe is closed */
-      /** change child state? **/
-      break;
-    default:  /* data in pipe */
-      break;
-  }
+  if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
+    EmptyIOBuffer (&job[0].stdout, job[0].stdout_fd);
+    EmptyIOBuffer (&job[0].stderr, job[0].stderr_fd);
+  } else {
+    /* read stdout buffer */
+    Nread = ReadtoIOBuffer (&job[0].stdout, job[0].stdout_fd);
+    switch (Nread) {
+      case -2:  /* error in read (programming error?  system level error?) */
+	fprintf (stderr, "serious IO error\n");
+	exit (2);
+      case -1:  /* no data in pipe */
+      case 0:   /* pipe is closed, change child state? **/
+      default:  /* data in pipe */
+	break;
+    }
   
-  /* read stderr buffer */
-  Nread = ReadtoIOBuffer (&job[0].stderr, job[0].stderr_fd);
-  switch (Nread) {
-    case -2:  /* error in read (programming error?  system level error?) */
-      fprintf (stderr, "serious IO error\n");
-      exit (2);
-    case -1:  /* no data in pipe */
-      break;
-    case 0:   /* pipe is closed */
-      /** change child state? **/
-      break;
-    default:  /* data in pipe */
-      break;
+    /* read stderr buffer */
+    Nread = ReadtoIOBuffer (&job[0].stderr, job[0].stderr_fd);
+    switch (Nread) {
+      case -2:  /* error in read (programming error?  system level error?) */
+	fprintf (stderr, "serious IO error\n");
+	exit (2);
+      case -1:  /* no data in pipe */
+      case 0:   /* pipe is closed, change child state? **/
+      default:  /* data in pipe */
+	break;
+    }
   }
   return (TRUE);
@@ -101,4 +100,7 @@
 
   int result, waitstatus;
+
+  /*** if child has exited, does the pipe hang around until it is flushed? ***/
+  /*** who closes the child stdout/stderr fd? */
 
   /* check local job status */
