简体   繁体   English

当一个进程被分叉时,中间指针表会发生什么? C 前叉 function

[英]What happens at the intermediate pointer table when a process is forked? C fork function

As you may know, the file descriptors in a process identifies a file operation (reading, writting...).您可能知道,进程中的文件描述符标识文件操作(读取、写入...)。 When we make operations with these files we have to communicate with the OS since it's the one which manages files.当我们对这些文件进行操作时,我们必须与操作系统进行通信,因为它是管理文件的那个。 With this purpose, the OS has a intermmediate pointer table in which for every single opened FD in every process, a entry is created.为此,操作系统有一个中间指针表,其中为每个进程中每个打开的 FD 创建一个条目。 This table contains information (file pointer, type of operation...) about all the opened FDs.此表包含有关所有打开的 FD 的信息(文件指针、操作类型...)。 My question is, what happens in this table when a process is forked?我的问题是,当一个进程被分叉时,这个表会发生什么? My intuitive answer is that the entries of the table that belong to the forked process are duplicated at the table in order to have other intermediate pointers in the child process but I haven't found any info about this so I'd be glad to someone clarify this.我直观的回答是,属于分叉进程的表条目在表中重复,以便在子进程中有其他中间指针,但我没有找到任何有关此的信息,所以我很高兴有人澄清这一点。

Thanks beforehand =)提前感谢=)

The table is duplicated.该表是重复的。 The duplication isn't just a memcpy() and outstanding IO only completes in the parent process.复制不仅仅是一个memcpy()和出色的 IO 仅在父进程中完成。 The child inherits all handles from the parent.子代继承父代的所有句柄。 The kernel file objects themselves are not duplicated but only their table references. kernel 文件对象本身重复,而只是它们的表引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM