Child Parent Relationship and Inheritance in C

后端 未结 5 1211
走了就别回头了
走了就别回头了 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:21

    There is no object-oriented inheritence in C.

    Fork'ing in C is basically the process being stopped while it is running, and an entire copy of it being made in (effectively) a different memory space, then both processes being told to continue. They will both continue from where the parent was paused. The only way you can tell which process you are in is to check the return value of the fork() call.

    In such a situation the child doesn't really inherit everything from the parent process, it's more like it gets a complete copy of everything the parent had.

提交回复
热议问题