Intel Interview Question
Software Engineer / DevelopersTeam: 3D graphics
Country: United States
Interview Type: Phone Interview
when a process call close function to close a particular open file through file descriptor.The file table of process decrement the reference count by one.But since parent and child both are holding the same file(there refrence count is 2 and after close it reduces to 1)since it is not zero so process still continue to use file without any problem.
See Terrence Chan UNIX system programming,(Unix kernel support for Files).
To answer the question we need to know about Copy On Write(COW) concept.
- srinivas April 10, 2012It means create a copy of the shared variable when the state of the variable changed by a process.
In the above concept File descriptors are shared variables.Those variables represents the files. For file we have 2 types f state changes.
1) open
2) close
If child closes the file descriptor then the state of the file going to changed.So it will create a copy for the file descriptor and it will close the copy.
If the child starts writing into the file COW it wont accrue.because the state of the file is note changed.So it can write into the file.