在我的示例应用程序中,它显示了SIGPIPE错误,尽管我忽略了我的main.m文件中的那个信号
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
signal(SIGPIPE, SIG_IGN);
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}gdb的反向跟踪是
#0 0x38579eb4 in mach_msg_trap ()
#1 0x3857a04c in mach_msg ()
#2 0x3605b044 in __CFRunLoopServiceMachPort ()
#3 0x36059d5e in __CFRunLoopRun ()
#4 0x35fccebc in CFRunLoopRunSpecific ()
#5 0x35fccd48 in CFRunLoopRunInMode ()
#6 0x328cf2ea in GSEventRunModal ()
#7 0x32939300 in UIApplicationMain ()
#8 0x000b6c52 in main (argc=1, argv=0x2fd4bc40) at /Users/bdsu/Desktop/Git_repo/VoipApp_iOS/VoipApp_iOS/main.m:17当我进入待机模式并返回时,就会发生此错误。我已经用IOS 6.0在IPAD上测试了它。Xcode版本为4.5/5.0。
发布于 2014-05-28 02:26:33
我的应用程序在后台需要连接互联网。但并不是所有的应用程序都可以在后台运行。您必须将应用程序的后台模式设置为voip应用程序,还可以使用其他一些选项使其能够在后台运行。默认情况下,IOS会在后台10分钟后暂停所有应用程序,而套接字将被关闭,这将导致sigpipe错误。这就是为什么我写了一个函数,当应用程序转到后台时,它会被调用,并保持应用程序的活力。这样,应用程序在后台运行时就可以连接到互联网上,并避免使用sigpipe。
https://stackoverflow.com/questions/19830244
复制相似问题