2 ms·
What are the uses of a process that shares address space with its parent?
by mattgreenrocks 15y ago
What are the uses of a process that shares address space with its parent?
- Someone 15y agoI wondered, too, so I had to look this up http://cm.bell-labs.com/magic/man2html/2/fork http://cm.bell-labs.com/magic/man2html/2/fork shows that it is not the whole address space: RFMEM If set, the child and the parent will share data and bss segments. Otherwise, the child inherits a copy of those segments. Other segment types, in particular stack segments, will be unaffected. May be set only with RFPROC. So, it basically is a way to start a process that shares all its globals (including static variables, I think) with another process, but not other memory. That is more secure than having threads, but also more restricted, as one cannot share heap-allocated structures between such processes. I guess this feature gets used most in Fortran code where nothing gets allocated dynamically. It also makes it easier to selective kill a thread of execution from the command line, but I do not see when that might be useful.