diff options
author | 2020-02-07 10:57:39 -0500 | |
---|---|---|
committer | 2022-03-29 12:02:38 +0200 | |
commit | 66a56a1e37e6df108c8dbcd99b7f60dec1fe4622 (patch) | |
tree | 421f0bd41d7fb1d5ac34141342c6e83f07bd2a5b | |
parent | fa85bb4fb05caf4f1fb35aef3a6f0de6083b9722 (diff) | |
download | libimobiledevice-66a56a1e37e6df108c8dbcd99b7f60dec1fe4622.tar.gz libimobiledevice-66a56a1e37e6df108c8dbcd99b7f60dec1fe4622.tar.bz2 |
Fix exit status logic
-rw-r--r-- | tools/idevicedebug.c | 12 |
1 files changed, 4 insertions, 8 deletions
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 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client | |||
171 | debugserver_decode_string(r + 1, strlen(r) - 1, &o); | 171 | debugserver_decode_string(r + 1, strlen(r) - 1, &o); |
172 | if (o != NULL) { | 172 | if (o != NULL) { |
173 | printf("Exit %s: %u\n", (r[0] == 'W' ? "status" : "due to signal"), o[0]); | 173 | printf("Exit %s: %u\n", (r[0] == 'W' ? "status" : "due to signal"), o[0]); |
174 | /* Use bash convention where signals cause an exit status of 128 + signal */ | ||
174 | *exit_status = o[0] + (r[0] == 'W' ? 0 : 128); | 175 | *exit_status = o[0] + (r[0] == 'W' ? 0 : 128); |
175 | free(o); | 176 | free(o); |
176 | o = NULL; | 177 | o = NULL; |
@@ -244,7 +245,6 @@ int main(int argc, char *argv[]) | |||
244 | char* response = NULL; | 245 | char* response = NULL; |
245 | debugserver_command_t command = NULL; | 246 | debugserver_command_t command = NULL; |
246 | debugserver_error_t dres = DEBUGSERVER_E_UNKNOWN_ERROR; | 247 | debugserver_error_t dres = DEBUGSERVER_E_UNKNOWN_ERROR; |
247 | int exit_status = -1; | ||
248 | 248 | ||
249 | /* map signals */ | 249 | /* map signals */ |
250 | signal(SIGINT, on_signal); | 250 | signal(SIGINT, on_signal); |
@@ -518,10 +518,10 @@ int main(int argc, char *argv[]) | |||
518 | if (response) { | 518 | if (response) { |
519 | log_debug("response: %s", response); | 519 | log_debug("response: %s", response); |
520 | if (strncmp(response, "OK", 2)) { | 520 | if (strncmp(response, "OK", 2)) { |
521 | dres = debugserver_client_handle_response(debugserver_client, &response, 1, &exit_status); | 521 | dres = debugserver_client_handle_response(debugserver_client, &response, 1, &res); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | if (exit_status >= 0) { | 524 | if (res >= 0) { |
525 | goto cleanup; | 525 | goto cleanup; |
526 | } | 526 | } |
527 | 527 | ||
@@ -571,9 +571,5 @@ cleanup: | |||
571 | if (device) | 571 | if (device) |
572 | idevice_free(device); | 572 | idevice_free(device); |
573 | 573 | ||
574 | if (exit_status > 0) { | 574 | return res; |
575 | return exit_status; | ||
576 | } else { | ||
577 | return res; | ||
578 | } | ||
579 | } | 575 | } |