Index: trunk/Ohana/src/opihi/pcontrol/KillJob.c
===================================================================
--- trunk/Ohana/src/opihi/pcontrol/KillJob.c	(revision 10661)
+++ trunk/Ohana/src/opihi/pcontrol/KillJob.c	(revision 17475)
@@ -3,52 +3,55 @@
 int KillJob (Job *job, Host *host) {
   
-  IOBuffer buffer;
   int status;
-  char *p;
 
   ASSERT (host != NULL, "host missing");
   ASSERT (job != NULL, "job missing");
-
   ASSERT (host == (Host *) job[0].host, "invalid host");
   ASSERT (job  == (Job *) host[0].job, "invalid job");
 
-  InitIOBuffer (&buffer, 0x100);
-
-  status = PclientCommand (host, "reset", PCLIENT_PROMPT, &buffer);
+  status = PclientCommand (host, "reset", PCLIENT_PROMPT, PCONTROL_RESP_KILL_JOB);
 
   /* check on success of pclient command */
   switch (status) {
     case PCLIENT_DOWN:
-      HarvestHost (host[0].pid);
       // unlink host & job
+      if (VerboseMode()) gprint (GP_ERR, "host %s is down\n", host[0].hostname);
       job[0].host = NULL;
       host[0].job = NULL;
+      HarvestHost (host[0].pid);
       PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
       PutJob (job, PCONTROL_JOB_CRASH, STACK_BOTTOM);
-      FreeIOBuffer (&buffer);
       return (FALSE);
 
-    case PCLIENT_HUNG:
-      // don't do anything drastic, just keep trying
-      // XXX move to which stack??
-      gprint (GP_ERR, "client is busy, not responding (KillJob)");
-      FreeIOBuffer (&buffer);
+    case PCLIENT_GOOD:
+      if (VerboseMode()) gprint (GP_ERR, "kill job on host %s\n", host[0].hostname);  
+      FlushIOBuffer (&host[0].comms_buffer);
+      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
+      PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
       return (TRUE);
-
-    case PCLIENT_GOOD:
-      if (VerboseMode()) gprint (GP_ERR, "message received (KillJob)\n");  
-      break;
 
     default:
       ABORT ("unknown status for pclient command");  
   }
+}
 
-  /** host is up, need to parse message **/
-  p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer);
+int KillJobResponse (Host *host) {
+  
+  int status;
+  char *p;
+  IOBuffer *buffer;
+  Job *job;
+
+  ASSERT (host != NULL, "host missing");
+  ASSERT (host[0].job, "missing job");
+  buffer = &host[0].comms_buffer;
+  job = (Job *) host[0].job;
+
+  /** check on response to pclient command **/
+  p = memstr (buffer[0].buffer, "STATUS", buffer[0].Nbuffer);
   ASSERT (p != NULL, "missing STATUS in pclient message");
-  if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer.buffer);
+  if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer[0].buffer);
 
   sscanf (p, "%*s %d", &status);
-  FreeIOBuffer (&buffer);
   gprint (GP_ERR, "client status: %d\n", status);
 
@@ -62,5 +65,5 @@
       return (FALSE);
     case 1:
-      gprint (GP_ERR, "killing job %s on %s\n", job[0].argv[0], host[0].hostname);
+      gprint (GP_ERR, "killed job %s on %s\n", job[0].argv[0], host[0].hostname);
       // unlink host & job
       job[0].host = NULL;
