簡體   English   中英

fork()時是否共享文件描述符?

[英]Are file descriptors shared when fork()ing?

假設我用open()打開一個文件。 然后我fork()我的程序。

父和子現在會共享文件描述符的相同偏移量嗎?

我的意思是如果我在父親那里寫作,那么兒童的偏移量也會改變嗎?

或者fork()后偏移量是否獨立?

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)). 

它們共享相同的偏移量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM