Tuesday, 17 September 2013

Why is it prohivited to use fork without exec in mac?

Why is it prohivited to use fork without exec in mac?

My question is quite simple. On Linux it is quite popular to use fork
without exec
However, I have found that on MacOS this is not possible (see fork manual)
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/fork.2.html
There are limits to what you can do in the child process. To be totally
safe you should restrict your-self yourself self to only executing
async-signal safe operations until such time as one of the exec functions
is called. All APIs, including global data symbols, in any framework or
library should be assumed to be unsafe after a fork() unless explicitly
documented to be safe or async-signal safe. If you need to use these
frameworks in the child process, you must exec. In this situation it is
reasonable to exec your-self. yourself. self.
This seems strange to me? What is the reason? Is it possible to workaround
it?

No comments:

Post a Comment