Matthew Gregan wrote:
At 2005-01-12T13:00:18+1300, Carl Cerecke wrote:
This could be partly solved by the OS by never reusing file descriptors lower than 3.
It could be, but that's probably not the right solution. It's extremely useful to be able to reopen stdin/stdout/stderr however you please, e.g. easy logging to a file by writing any log output to stderr, then reopening stderr as a log file, or think of what the shell does with "> /dev/null". If open()-like calls were prohibited in the way that you suggest, you'd need to create a new API for remapping stdin/stdout/stderr.
Isn't that what dup2 is for?
Cheers, Carl.
