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.