Skip to content

Commit

Permalink
Return an error code when timeout occurs while running an app.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusts Kaksis committed Jul 31, 2017
1 parent c811169 commit 5d55cec
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/ios-deploy/ios-deploy.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@

// Error codes we report on different failures, so scripts can distinguish between user app exit
// codes and our exit codes. For non app errors we use codes in reserved 128-255 range.
const int exitcode_timeout = 252;
const int exitcode_error = 253;
const int exitcode_app_crash = 254;

Expand Down Expand Up @@ -1657,37 +1658,42 @@ void device_callback(struct am_device_notification_callback_info *info, void *ar

void timeout_callback(CFRunLoopTimerRef timer, void *info) {
if (found_device && (!detect_only)) {
// App running for too long
NSLog(@"[ !! ] App is running for too long");
exit(exitcode_timeout);
return;
} else if ((!found_device) && (!detect_only)) {
if(best_device_match != NULL) {
// Device not found timeout
if (best_device_match != NULL) {
NSLogVerbose(@"Handling best device match.");
handle_device(best_device_match);

CFRelease(best_device_match);
best_device_match = NULL;
}

if(!found_device)
if (!found_device)
on_error(@"Timed out waiting for device.");
}
else
{
if (!debug) {
NSLogOut(@"[....] No more devices found.");
}

if (detect_only && !found_device) {
exit(exitcode_error);
return;
} else {
int mypid = getpid();
if ((parent != 0) && (parent == mypid) && (child != 0))
{
NSLogVerbose(@"Timeout. Killing child (%d) tree.", child);
kill_ptree(child, SIGHUP);
}
}
exit(0);
// Device detection timeout
if (!debug) {
NSLogOut(@"[....] No more devices found.");
}

if (detect_only && !found_device) {
exit(exitcode_error);
return;
} else {
int mypid = getpid();
if ((parent != 0) && (parent == mypid) && (child != 0))
{
NSLogVerbose(@"Timeout. Killing child (%d) tree.", child);
kill_ptree(child, SIGHUP);
}
}
exit(0);
}
}

Expand Down

0 comments on commit 5d55cec

Please sign in to comment.