A child process created using fork() call inherits file descriptor table of its parent process. In my child process, I would like know about the file descriptors that it inherited from its parent process (and their respective file pointers or the file names that it is pointing at). I know that that entries can be stored in variables that the child process inherits. But, I would like to know about a programming way to retrieve this information.
Asked
Active
Viewed 831 times
0
-
1The programming way to retrieve it is to do exactly what you said you already know you can do: store the name and their associated file pointers in a relational construct that can be referred to by the child process after the fork. Anything outside of that is [highly platform-dependent](https://stackoverflow.com/questions/2046515/from-file-object-to-file-name) at best, and not possible more than likely. – WhozCraig Oct 21 '18 at 18:49
2 Answers
0
You can iterate over all file descriptors starting from 0 and pass them to fstat
.

Volker Stolz
- 7,274
- 1
- 32
- 50