Index: trunk/Ohana/src/opihi/pcontrol/pclient.c
===================================================================
--- trunk/Ohana/src/opihi/pcontrol/pclient.c	(revision 3187)
+++ trunk/Ohana/src/opihi/pcontrol/pclient.c	(revision 3203)
@@ -4,22 +4,30 @@
 # define PCLIENT_PROMPT "pclient:"
 
-# define DOWN  0
-# define HUNG -1
-
 int PclientCommand (Host *host, char *command, IOBuffer *buffer) {
 
-  /* send command to client */
-  status = write (host[0].stdin, command, strlen(command));
-  if ((status == -1) && (errno == EPIPE)) return (DOWN);
+  int i;
+  int status;
+  char *line;
+  
+  /* send command to client (adding on \n) */
+  ALLOCATE (line, char, MAX (1, strlen(command)));
+  sprintf (line, "%s\n", command);
+  status = write (host[0].stdin, line, strlen(line));
+  free (line);
+
+  /* is pipe still open? */
+  if ((status == -1) && (errno == EPIPE)) return (PCLIENT_DOWN);
   
   /* watch for response - wait up to 1 second */
-  p = NULL;
+  line = NULL;
   status = -1;
-  for (i = 0; (i < PCLIENT_TIMEOUT) && (status == -1) && (p == NULL); i++) {
+  for (i = 0; (i < PCLIENT_TIMEOUT) && (status == -1) && (line == NULL); i++) {
     status = ReadtoIOBuffer (buffer, host[0].stdout);
-    p = memstr (buffer[0].buffer, PCLIENT_PROMPT, buffer[0].Nbuffer);
+    line = memstr (buffer[0].buffer, PCLIENT_PROMPT, buffer[0].Nbuffer);
   }
-  if (status ==  0) return (DOWN);
-  if (status == -1) return (HUNG);
-  return (TRUE);
+  if (status ==  0) return (PCLIENT_DOWN);
+  if (status == -1) return (PCLIENT_HUNG);
+  return (PCLIENT_GOOD);
 }
+
+/* memstr returns a view, not an allocated string : don't free */
