文件描述符 File Descriptors
文件描述標誌 File Descriptors Flag
文件狀態標誌 File Status Flag
文件描述符是一個標示,非負整數,類似於windows裏的句柄,爲了與標準C保持一致(標準C裏的文件的讀寫都是通過File Pointer)UNIX採用了這樣的三級結構,我混淆於文件描述標誌和文件狀態標誌,還是看英文來的有效,fd flag = close_on_exec。是在一個文件在某進程中的標示,而由於文件可以被多個進程打開,因此這個file status flag能被很多個進程訪問到,它表示的是這個文件在此刻的讀寫等標示。下面附上一份原文。
Note the difference in scope between the file descriptor flags and the file status flags. The former apply only to a single descriptor in a single process, whereas the latter apply to all descriptors in any process that point to the given file table entry. When we describe the fcntl function in Section 3.14, we'll see how to fetch and modify both the file descriptor flags and the file status flags.