Artificial intelligent assistant

What happens to the file structs of processes after execve If I understand the man pages correctly, the fd table of a process that forks and execves are copied to the the child process and survive the execve. On the other hand, any other memory mapping is destroyed after the execve. Therefor I expexted file structs to be deleted when a proc does this (forks and execves). Notwithstanding, I found an example in my uni's textbook that asked; "How many file structs would there be in the kernel if 10 processes opened a file, and then half of them forked while the other half execved?" The answer was 10 "because children share the file struct." However, I thought it would be 5 since the procs that execved would have their file structs destroyed So, would that mean that file structs remain in the kernel after an execve?

Given that the open file descriptors survive the `execve` (unless they are marked as closing on `execve`), yes, the corresponding structures in the kernel also survive the `execve`. Otherwise there wouldn’t be any way for the kernel to figure out what the still-open file descriptors correspond to.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 122ec6f75bd6dce6a7702d0c377b664d