fork Cocoa进程并重新初始化Cocoa。怎么样? [英] fork Cocoa process and re-init Cocoa. how?

查看:432
本文介绍了fork Cocoa进程并重新初始化Cocoa。怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图 fork()一个Cocoa过程,并设置一个新的Cocoa / ObjC环境,但我得到的错误:

 该进程已分叉,您不能安全地使用此CoreFoundation功能。你必须执行()。 
打开__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY ___ YOU_MUST_EXEC __()进行调试。有没有办法在分叉过程中重新初始化Cocoa / ObjC?






我知道有关 fork()的文档确实有限制,我想知道是否还有办法做,而不只是文档说的。



我试图读取处理execve系统调用(bsd / kern / kern_exec.c)的XNU内核的源代码但我不是用于代码,我不能轻易地说,这是可能或不

解决方案

Mac OS X严重限制了您在叉子后可以执行的操作,但 exec ing。请参阅 fork man的CAVEATS部分页面。允许的操作不包括使用Cocoa或CoreFoundation,因此您必须调用 exec 才能启动一个新程序。


I tried to fork() a Cocoa process and setup a new Cocoa/ObjC environment but I get the error:

The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

Is there a way to re-initialize Cocoa/ObjC in the forked process?


I know that the documentation about fork() does say it is limited, however I wonder if there is still a way to do it, not just what the documentation says.

I tried to read the source code of the XNU kernel which handles the execve syscall (bsd/kern/kern_exec.c) but I am not that used to the code that I cannot easily say wether it is possible or not to do something similar in userspace or not.

解决方案

Mac OS X severely limits what you can do after a fork without execing. See the CAVEATS section of the fork man page. The allowed actions do not include using Cocoa or CoreFoundation, so you must call exec to start a new program.

这篇关于fork Cocoa进程并重新初始化Cocoa。怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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