Trying to use cydia libraries: NSTask on Jailbroken iphone crashes with Segmentation fault: 11(尝试使用 cydia 库:越狱 iphone 上的 NSTask 因分段错误而崩溃:11)
问题描述
我想从带有图标的 GUI 应用程序运行 dpkg(或/bin 或/usr/bin 目录中来自 cydia 的任何其他二进制库文件),例如 mobileterminal、ifile、myfile、cydia、alertscript 等等其他人可以.他们如何访问图书馆?此代码有效,进程的标准输出打印在 nslog 中,但随后它立即因分段错误而崩溃:11.这是在我的 viewdidload 函数中.这不会发生在模拟器中,只有我的 iPhone 4.很奇怪.已尝试以移动设备和 root 身份运行.该应用程序位于/Applications 文件夹下.这是我的代码.
I want to run dpkg ( or any other binary library files from cydia in the /bin or /usr/bin directories) from a GUI app with an icon, like mobileterminal, ifile, myfile, cydia, alertscript, and so many others can. How do they accesses the libraries? This code works, and the stdout of the process is printed in nslog but then it immediately crashes with Segmentation fault: 11. this is in my viewdidload function. This DOES NOT OCCUR IN THE SIMULATOR, only my iPhone 4. weird. have tried running as both mobile and root. the app is under /Applications folder. Here's my code.
我正在使用 xcode 的雪豹版本,并且刚刚更新为 lion,但我认为这可能不是问题?我的 iPhone 是 ios5.0.1.我测试时会发布.
I'm using the snow leopard version of xcode, and just updated to lion but I'm thinking that's probably not the issue? My iPhone is ios5.0.1. will post when I test it.
NSString * workingdir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSTask * nstaskvar=[NSTask new];//note the NSTask.h file included!
NSPipe * outputPipe = [NSPipe pipe];
[nstaskvar setLaunchPath:@"/bin/ls"];
[nstaskvar setArguments:[NSArray arrayWithObjects:@"/usr",nil]];
[nstaskvar setCurrentDirectoryPath:workingdir];
[nstaskvar setStandardOutput:outputPipe];
[nstaskvar setStandardInput:[NSPipe pipe]];
[nstaskvar launch];
NSString * outputstring = [[[NSString alloc] initWithData:[[outputPipe fileHandleForReading] readDataToEndOfFile] encoding:NSUTF8StringEncoding] autorelease];//readDataToEndOfFile reads until file is closed, which happens when process exits :) (i couldnt get waitUntilExit to work)
NSLog(@"%@", outputstring);
[nstaskvar release];
[outputPipe release];
推荐答案
解决了!在我升级到 xcode 4.3.2(lion 版本)后,模拟器因 exc_bad_access
而崩溃,所以我启用了僵尸,发现它是最后两行 [nstaskvar release];[outputPipe release];
导致问题.
Solved it! After I upgraded to xcode 4.3.2, the lion version, the simulator crashed with exc_bad_access
so i enabled zombies and found it was the last two lines [nstaskvar release]; [outputPipe release];
that caused the problem.
我将它们都禁用了,然后它就消失了,现在在我的 iphone 上运行良好:D.
I disabled them both and it went away, and now works great on my iphone :D.
这篇关于尝试使用 cydia 库:越狱 iphone 上的 NSTask 因分段错误而崩溃:11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:尝试使用 cydia 库:越狱 iphone 上的 NSTask 因分段错


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01