Подтвердить что ты не робот

Разделяются ли файловые дескрипторы, когда fork() ing?

Допустим, я открываю файл с помощью open(). Затем я fork() моей программы.

Будут ли папа и ребенок использовать одно и то же смещение для файлового дескриптора?

Я имею в виду, если я сделаю запись в моем отце, смещение также будет изменено у ребенка?

Или смещения будут независимыми после fork()?

4b9b3361

Ответ 1

От fork(2):

  *  The child inherits copies of the parent’s set of open file  descrip-
     tors.   Each  file  descriptor  in the child refers to the same open
     file description (see open(2)) as the corresponding file  descriptor
     in  the parent.  This means that the two descriptors share open file
     status flags, current file offset, and signal-driven I/O  attributes
     (see the description of F_SETOWN and F_SETSIG in fcntl(2)).

Ответ 2

Они имеют одинаковое смещение.