Fix exit status logic
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index a5559e1..ca4cb18 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -171,6 +171,7 @@
 		debugserver_decode_string(r + 1, strlen(r) - 1, &o);
 		if (o != NULL) {
 			printf("Exit %s: %u\n", (r[0] == 'W' ? "status" : "due to signal"), o[0]);
+			/* Use bash convention where signals cause an exit status of 128 + signal */
 			*exit_status = o[0] + (r[0] == 'W' ? 0 : 128);
 			free(o);
 			o = NULL;
@@ -244,7 +245,6 @@
 	char* response = NULL;
 	debugserver_command_t command = NULL;
 	debugserver_error_t dres = DEBUGSERVER_E_UNKNOWN_ERROR;
-	int exit_status = -1;
 
 	/* map signals */
 	signal(SIGINT, on_signal);
@@ -518,10 +518,10 @@
 				if (response) {
 					log_debug("response: %s", response);
 					if (strncmp(response, "OK", 2)) {
-						dres = debugserver_client_handle_response(debugserver_client, &response, 1, &exit_status);
+						dres = debugserver_client_handle_response(debugserver_client, &response, 1, &res);
 					}
 				}
-				if (exit_status >= 0) {
+				if (res >= 0) {
 					goto cleanup;
 				}
 
@@ -571,9 +571,5 @@
 	if (device)
 		idevice_free(device);
 
-	if (exit_status > 0) {
-		return exit_status;
-	} else {
-		return res;
-	}
+	return res;
 }