Does POSIX standardize the file descriptor numbers

cfile-descriptorsposixstandard

Does POSIX mandate that stdin is 0, stdout is 1 and stderr is 2 or is this only a convention? Do other systems diverge from that convention or is it a safe assumption?

Best Answer

It seems that they are standardized in the POSIX spec,

It seems ISO C is relatively mute on this allowing the kernel to assign whatever it wants to the descriptors known as STDOUT, STDERR, and STDIN. But that the POSIX docs on unistd.h are explicit about what they should resolve to at that level.

Other Operating Systems