linux - How to copy the file description when forking instead of sharing? -


when process forks, child share parent file description open before forking.

is there way make child have own copy of file description (that includes offset , file status flag)?

i need since don't want both parent , child share same offset of file; if 1 process has done read, don't want offset of file second process changed.

there's both 'open file descriptor' , 'open file description'. when file opened open(), both file descriptor , file description created. when file descriptor duplicated (dup() or dup2()), 2 descriptors refer same open file description.

on fork(), file descriptors in parent copied (duplicated) in child; descriptor in parent , child both point same open file description.

the child process shall have own copy of parent's file descriptors. each of child's file descriptors shall refer same open file description corresponding file descriptor of parent.

there's no way have work otherwise — you'd have close , reopen file separate open file description.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -