Handle abort
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index 27eaa4e..c596213 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -130,6 +130,8 @@
 	} else if (r[0] == 'T') {
 		/* thread stopped information */
 		log_debug("Thread stopped. Details:\n%s", r + 1);
+                /* "Thread stopped" seems to happen when assert() fails. Use bash convention where signals cause an exit status of 128 + signal */
+                *exit_status = 128 + SIGABRT;
                 /* Break out of the loop. */
 		dres = DEBUGSERVER_E_UNKNOWN_ERROR;
 	} else if (r[0] == 'E') {
@@ -487,6 +489,10 @@
 					log_debug("response: %s", response);
 					if (strncmp(response, "OK", 2)) {
 						dres = debugserver_client_handle_response(debugserver_client, &response, &res);
+						if (dres != DEBUGSERVER_E_SUCCESS) {
+							debug_info("failed to process response; error %d; %s", dres, response);
+							break;
+						}
 					}
 				}
 				if (res >= 0) {
@@ -511,7 +517,9 @@
 				response = NULL;
 			}
 
-			res = (dres == DEBUGSERVER_E_SUCCESS) ? 0: -1;
+                        if (res < 0) {
+                          res = (dres == DEBUGSERVER_E_SUCCESS) ? 0: -1;
+                        }
 		break;
 	}