Index: trunk/Ohana/src/opihi/pcontrol/host.c
===================================================================
--- trunk/Ohana/src/opihi/pcontrol/host.c	(revision 3189)
+++ trunk/Ohana/src/opihi/pcontrol/host.c	(revision 3203)
@@ -3,7 +3,8 @@
 int host (int argc, char **argv) {
 
-  int pid, status;
+  int N, Delete, Off, On;
+  Host *host;
 
-  /* this section needs some help: find the specified host in the queues */
+  /* this section needs some help: find the specified host in the stacks */
   Delete = FALSE;
   if ((N = get_argument (argc, argv, "-delete"))) {
@@ -12,5 +13,5 @@
   }
  
-  /* this section needs some help: find the specified host in the queues */
+  /* this section needs some help: find the specified host in the stacks */
   Off = FALSE;
   if ((N = get_argument (argc, argv, "-off"))) {
@@ -29,9 +30,10 @@
   
   if (Delete) {
-    host = FindHost (argv[1], PCONTROL_HOST_OFF);
-    if (host == NULL) {
+    N = FindNamedHost (argv[1], PCONTROL_HOST_OFF);
+    if (N < 0) {
       fprintf (stderr, "host %s is not OFF\n", argv[1]);
       return (FALSE);
     }
+    host = GetHost (PCONTROL_HOST_OFF, N);
     DelHost (host);
     return (TRUE);
@@ -45,5 +47,5 @@
     }
     host = GetHost (PCONTROL_HOST_OFF, N);
-    PutHost (host, PCONTROL_HOST_DOWN, QUEUE_BOTTOM);
+    DownHost (host);
     return (TRUE);
   }
@@ -52,18 +54,22 @@
     N = FindNamedHost (argv[1], PCONTROL_HOST_IDLE);
     if (N >= 0) {
-      host = GetHost (PCONTROL_HOST_OFF, N);
-      PutHost (host, PCONTROL_HOST_OFF, QUEUE_BOTTOM);
+      host = GetHost (PCONTROL_HOST_IDLE, N);
+      CLOSE (host[0].stdin);
+      CLOSE (host[0].stdout);
+      CLOSE (host[0].stderr);
+      PutHost (host, PCONTROL_HOST_OFF, STACK_BOTTOM);
       return (TRUE);
     }
     N = FindNamedHost (argv[1], PCONTROL_HOST_DOWN);
     if (N >= 0) {
-      host = GetHost (PCONTROL_HOST_OFF, N);
-      PutHost (host, PCONTROL_HOST_OFF, QUEUE_BOTTOM);
+      host = GetHost (PCONTROL_HOST_DOWN, N);
+      PutHost (host, PCONTROL_HOST_OFF, STACK_BOTTOM);
       return (TRUE);
     }
     N = FindNamedHost (argv[1], PCONTROL_HOST_BUSY);
     if (N >= 0) {
-      host = GetHost (PCONTROL_HOST_OFF, N);
-      PutHost (host, PCONTROL_HOST_OFF, QUEUE_BOTTOM);
+      host = GetHost (PCONTROL_HOST_BUSY, N);
+      host[0].markoff  = TRUE;
+      PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM);
       return (TRUE);
     }
