Why does the kernel increment the reference count for each `file` structure during the `fork()` operation? How does this ensure proper resource management?
The kernel increases the reference count for each file structure that is shared between the child and parent process. This reference count keeps track of how many file descriptors(across different processes) refer to the same open file. When a file descriptor is duplicated, the reference count is increased to reflect that multiple processes now reference the same file.