9 ms·
fork() was always very restricted in when it could be used and really dangerous even then. It was made for a world where process == thread, and since that cease
by dmitrygr 21d ago
fork() was always very restricted in when it could be used and really dangerous even then. It was made for a world where process == thread, and since that ceased to be true it's been a large footgun. Use spawn if you need to launch a process, reconsider your life if your immediate post-fork() syscall is not exec()
- edelbitter 21d agoBut what would the equivalent "do the expensive preparation 1 time, then re-use copy-on-write memory N times" pattern look like, after reconsidering my life?
- cestith 21d agoThe manpage suggests if you need the child to be the same as the parent to exec a copy of the parent in the child right after forking.
- oasisaimlessly 21d agoThis doesn't allow reusing initialization work via CoW mappings (like GP was asking about).
- cestith 21d agoThis is an artifact of doing as the platform is documented to work. You can do what the man page says, or you can do the opposite. The whole article is about how forking on macOS is troublesome.
- zbentley 21d agoIt looks like threads and a copy-on-write data structure or memory mapping.