Under Unix / Linux, what happens to my active RAII objects upon forking? Will there be double deletions?
What is with copy construction and -assignment? How to make sure nothing bad happens?
Under Unix / Linux, what happens to my active RAII objects upon forking? Will
Share
fork(2)creates a full copy of the process, including all of its memory. Yes, destructors of automatic objects will run twice – in the parent process and in the child process, in separate virtual memory spaces. Nothing “bad” happens (unless of course, you deduct money from an account in a destructor), you just need to be aware of the fact.