Skip to content

Commit 18406e8

Browse files
committed
Explicit exit on launch failure to ensure auto exit and safe quite doesn’t end up waiting forever
1 parent 8ee3cda commit 18406e8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/ios-deploy/ios-deploy.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,11 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
628628
CFMutableStringRef pmodule = CFStringCreateMutableCopy(NULL, 0, (CFStringRef)LLDB_FRUITSTRAP_MODULE);
629629

630630
CFRange rangeLLDB = { 0, CFStringGetLength(pmodule) };
631-
631+
632+
CFStringRef exitcode_error_str = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d"), exitcode_error);
633+
CFStringFindAndReplace(pmodule, CFSTR("{exitcode_error}"), exitcode_error_str, rangeLLDB, 0);
634+
rangeLLDB.length = CFStringGetLength(pmodule);
635+
632636
CFStringRef exitcode_app_crash_str = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d"), exitcode_app_crash);
633637
CFStringFindAndReplace(pmodule, CFSTR("{exitcode_app_crash}"), exitcode_app_crash_str, rangeLLDB, 0);
634638
rangeLLDB.length = CFStringGetLength(pmodule);

src/scripts/lldb.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ def run_command(debugger, command, result, internal_dict):
5555
#This env variable makes NSLog, CFLog and os_log messages get mirrored to stderr
5656
#https://stackoverflow.com/a/39581193
5757
launchInfo.SetEnvironmentEntries(['OS_ACTIVITY_DT_MODE=enable'], True)
58-
58+
5959
lldb.target.Launch(launchInfo, error)
60-
lockedstr = ': Locked'
61-
if lockedstr in str(error):
62-
print('\\nDevice Locked\\n')
63-
os._exit(254)
64-
else:
65-
print(str(error))
60+
if error.Fail():
61+
if ': Locked' in str(error):
62+
print('\\nDevice Locked\\n')
63+
else:
64+
print(str(error))
65+
#force exit to make sure autoexit or safequit don't end up waiting forever
66+
os._exit({exitcode_error})
6667

6768
def safequit_command(debugger, command, result, internal_dict):
6869
process = lldb.target.process

0 commit comments

Comments
 (0)