diff options
author | Ben Wagner | 2020-02-07 10:57:39 -0500 |
---|---|---|
committer | Nikias Bassen | 2022-03-29 12:02:38 +0200 |
commit | 66a56a1e37e6df108c8dbcd99b7f60dec1fe4622 (patch) | |
tree | 421f0bd41d7fb1d5ac34141342c6e83f07bd2a5b /tools | |
parent | fa85bb4fb05caf4f1fb35aef3a6f0de6083b9722 (diff) | |
download | libimobiledevice-66a56a1e37e6df108c8dbcd99b7f60dec1fe4622.tar.gz libimobiledevice-66a56a1e37e6df108c8dbcd99b7f60dec1fe4622.tar.bz2 |
Fix exit status logic
Diffstat (limited to 'tools')
-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 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 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) 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 @@ cleanup: if (device) idevice_free(device); - if (exit_status > 0) { - return exit_status; - } else { - return res; - } + return res; } |