gpt4 book ai didi

ubuntu - vfork() child 拥有什么特权?

转载 作者:行者123 更新时间:2023-12-04 18:31:44 26 4
gpt4 key购买 nike

使用 vfork() 创建的进程是否具有与创建者进程(即父进程)相同的权限级别?

示例:如果我以 root 身份运行进程,vfork() 子进程是否拥有相同的执行权限?

最佳答案

fork() 的开放组 (POSIX) 规范说:

The fork() function shall create a new process. The new process (child process) shall be an exact copy of the calling process (parent process) except as detailed below:



由于该文本下方没有提及 UID/GID,因此您可以推断这些属性是继承的。

这些属性最终会通过调用适当的属性更改函数( setuid 等)或 exec 来更改。 .

vfork() 的旧(POSIX 2004 或更早版本)规范很相似:

The vfork() function shall be equivalent to fork(), except that the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec family of functions.


vfork()的规范已从 POSIX 2008(又名 POSIX 2016)中删除。

关于ubuntu - vfork() child 拥有什么特权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47827680/

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