尝试使用 cydia 库:越狱 iphone 上的 NSTask 因分段错

Trying to use cydia libraries: NSTask on Jailbroken iphone crashes with Segmentation fault: 11(尝试使用 cydia 库:越狱 iphone 上的 NSTask 因分段错误而崩溃: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
How to fix ‘TIC SSL Trust Error’ in iOS?(如何修复 iOS 中的“TIC SSL 信任错误?)
How to install self signed certificate in iOS 10(如何在 iOS 10 中安装自签名证书)
quot;Server certificate untrustedquot; error in iPhone application(“服务器证书不受信任iPhone应用程序中的错误)