The fdopen
function returns a new stream for the file descriptor
filedes.
The opentype argument is interpreted in the same way as for the
fopen
function (see Opening Streams), except that
the `b' option is not permitted; this is because GNU makes no
distinction between text and binary files. Also, "w"
and
"w+"
do not cause truncation of the file; these have an effect only
when opening a file, and in this case the file has already been opened.
You must make sure that the opentype argument matches the actual
mode of the open file descriptor.
The return value is the new stream. If the stream cannot be created
(for example, if the modes for the file indicated by the file descriptor
do not permit the access specified by the opentype argument), a
null pointer is returned instead.
In some other systems, fdopen
may fail to detect that the modes
for file descriptor do not permit the access specified by
opentype
. The GNU C library always checks for this.