The discussion at Pre-RFC overhaul Command for 2021 ed made me think of a question that's been bugging me for a while now; why isn't there a fork()
function in std::process
? I know that there has to be a good reason, but I have no idea what it is...
It's OS specific and it seems potentially very unsafe, particularly in multi-threaded programs. See fork(2) and signal-safety(7).
@chrisd Thank you for the quick reply.
I see what you mean now, I didn't realize it was such a problem.
Also see the discussion around before_exec
, which was a safe way to execute code in the forked process, and was deprecated in favor of an unsafe
function:
Also, you can easily call libc::fork()
, if pre_exec
isn't sufficient for your use case.
No, no particular use case at this time; I didn't mean to imply that it should be added, I knew that this group would have already considered it, and so the fact that it wasn't available was for a good reason. I just didn't know what that reason was. Now I do. Thank you all for clarifying the situation for me.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.