在获取了root的Daemon中使用CFMessagePortRef,服务启动了,但是马上又重启了,log如下
Jul 11 09:08:47 oh TestDaemond[624]: iOSRE: rootdaemond is launched!
Jul 11 09:08:47 oh com.apple.launchd[1] (com.test.daemond): (com.test.daemond) Throttling respawn: Will start in 10 seconds
Jul 11 09:08:57 oh TestDaemond[626]: MS:Notice: Injecting: com.tcapp.tcapp [TestDaemond] (847.27)
Jul 11 09:08:57 oh TestDaemond[626]: iOSRE: rootdaemond is launched!
同样的代码,在tweak中挂在Springboard中就是能正常的,大神们给看下咋回事呢?
代码如下
int main(int argc, char **argv, char **envp)
{
NSLog(@“iOSRE: rootdaemond is launched!”);
CFMessagePortRef mMsgPortListenner = CFMessagePortCreateLocal(kCFAllocatorDefault,CFSTR(LOCAL_MACH_PORT_NAME_DAEMOND),onRecvMessageCallBack, NULL, NULL);
CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, mMsgPortListenner, 0);
NSLog(@"TouchControl source=:%@",source);
CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
return 0;
}