I'm opening a stream with funopen
FILE *fin = funopen(cookie, readfn, NULL, NULL, closefn);
if (fin == NULL)
{
handle_error();
return -1;
}
int fdin = fileno(fin);
The call to funopen succeeds but fileno(fin)
returns -1
.
How can I get the file descriptor? Thanks.
A FILE
opened with funopen
(which is not part of any standard, by the way; AFAIK it's a BSD extension) does not have an underlying file descriptor. It has the cookie instead. I don't know what you wanted the file descriptor for, but you're probably out of luck.