I am doing a project for my school where I have to build a shell.
The thing is when I got to do the "open [file] [mode]" command for my shell, I have to keep a list of the opened files with their names, file descriptors and their mode. My problem resides in the fact that I don't know how to actually get the names of those 3 reserved file descriptors to include them in the list (since I have to do it). I know that file descriptor 0 is reserved for standard input, the 1 for standard output and the 2 for standard error output, but I think that if it's possible, I should get their names from some function or library.
I've searched in several sites of internet and I learned a lot of useful things, but I couldn't get a solution for this particular problem, so my last option is asking here and see if someone can enlighten me.
Thank you for your time.
I think maybe you want something like this:
and similar for
stdout/stderrNote: do not close the standard streams!