linux - Is file object local to every process or System wide? -


as linux device driver developer in idea file object local structure every process , address available in fd table corresponding fd. when came across section 5.6 in linux programming interface michale kerrisk states that

two different file descriptors refer same open file description share file offset value. therefore, if file offset changed via 1 file descriptor (as consequence of calls read(), write(), or lseek()), change visible through other file descriptor. applies both when 2 file descrip tors belong same process , when belong different processes.

i befuddled...kindly 1 me improve understanding.

each process have own file descriptor table, , each time file open()ed yields separate file description. there sanity there!

the exception when file descriptor duplicated, either within process (via dup()) or across processes (by 1 process fork()ing copy same fds, or passing file descriptor through unix domain socket). when happens, 2 descriptors end sharing properties each other, including offset.

this not bad thing. means, instance, 2 processes both writing shared file descriptor not end overwriting each other's output. can have unexpected results, though. it's not you'd end without knowing it.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -