gpt4 book ai didi

linux - 克隆系统调用 - 我可以在父进程中取消分配堆栈内存吗?

转载 作者:太空宇宙 更新时间:2023-11-04 10:11:28 27 4
gpt4 key购买 nike

clone 返回后,在父进程中释放传递给 clonechild_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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com