Child Parent Relationship and Inheritance in C

后端 未结 5 1313
走了就别回头了
走了就别回头了 2021-02-03 12:52

I am totally new with C.

  1. What are the process items that are inherited in a child created using fork();?

  2. What are the process items

5条回答
  •  青春惊慌失措
    2021-02-03 13:30

    The fork(2) man page on your system (man fork) should give you better details but generally the child only inherits the parent's list of file descriptors, including open files, sockets, and process handles.

    From my system's man page (Mac OS X 10.6.6):

    The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an lseek(2) on a descriptor in the child process can affect a subsequent read or write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly cre- ated processes as well as to set up pipes.

提交回复
热议问题