console-client: Produce unique exit code when escaped

This allows programs which supervise obmc-console-client to know the
difference between a clean exit and one where the shell had a deliberate
escape.

Tested:
    Ran on a machine and checked that issuing an escape generated a
    return code of 2.

Change-Id: Ica698134f60ba17b445c12b9c95faed43f90f309
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/console-client.c b/console-client.c
index 3f3f519..6baeb0b 100644
--- a/console-client.c
+++ b/console-client.c
@@ -29,10 +29,13 @@
 
 #include "console-server.h"
 
+#define EXIT_ESCAPE 2
+
 enum process_rc {
 	PROCESS_OK = 0,
 	PROCESS_ERR,
 	PROCESS_EXIT,
+	PROCESS_ESC,
 };
 
 enum esc_type {
@@ -77,7 +80,7 @@
 				esc_state->state = '\0';
 				break;
 			}
-			return PROCESS_EXIT;
+			return PROCESS_ESC;
 		case '~':
 			if (esc_state->state != '\r') {
 				esc_state->state = '\0';
@@ -117,7 +120,7 @@
 			esc_state->pos = 0;
 
 		if (esc_state->str[esc_state->pos] == '\0') {
-			prc = PROCESS_EXIT;
+			prc = PROCESS_ESC;
 			break;
 		}
 	}
@@ -239,7 +242,7 @@
 {
 	struct console_client _client, *client;
 	struct pollfd pollfds[2];
-	enum process_rc prc;
+	enum process_rc prc = PROCESS_OK;
 	int rc;
 
 	client = &_client;
@@ -277,7 +280,6 @@
 	if (rc)
 		goto out_fini;
 
-	prc = PROCESS_OK;
 	for (;;) {
 		pollfds[0].fd = client->fd_in;
 		pollfds[0].events = POLLIN;
@@ -303,6 +305,8 @@
 
 out_fini:
 	client_fini(client);
+	if (prc == PROCESS_ESC)
+		return EXIT_ESCAPE;
 	return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }