尝试使用cydia库:越狱的iPhone上的NSTask因分段错误而崩溃:11 [英] Trying to use cydia libraries: NSTask on Jailbroken iphone crashes with Segmentation fault: 11

查看:186
本文介绍了尝试使用cydia库:越狱的iPhone上的NSTask因分段错误而崩溃:11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从带有图标的GUI应用程序中运行dpkg(或/ bin或/ usr / bin目录中cydia中来自cydia的任何其他二进制库文件),例如mobileterminal,ifile,myfile,cydia,alertscript等其他人可以。他们如何访问图书馆?此代码有效,并且该进程的stdout在nslog中打印,但随后由于Segmentation Fault: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之后,模拟器崩溃,并导致 exc_bad_access 崩溃,因此我启用了僵尸,并发现这是最后两行 [ nstaskvar版本]; [outputPipe版本]; 导致了问题。

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆