在 clone
返回后,在父进程中释放传递给 clone
的 child_stack
参数的堆栈缓冲区是否安全(如果 CLONE_VM
未指定)?
最佳答案
引用clone man page :
If CLONE_VM is not set, the child process runs in a separate copy of the memory space of the calling process at the time of clone(). Memory writes or file mappings/unmappings performed by one of the processes do not affect the other, as with fork(2).
这还包括 child_stack
,它只是像其他所有东西一样被复制了。
所以是的, parent 可以取消分配它, child 使用一个副本,而不是原来的。
关于linux - 克隆系统调用 - 我可以在父进程中取消分配堆栈内存吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48825108/