T. Webster
T. Webster

Reputation: 10109

get address of Linux file descriptor

There is fileno to get the file descriptor of a FILE*.

How do you get the address for the FILE* given a file descriptor number, e.g. as returned from pipe?

fileno pipe

Upvotes: 2

Views: 919

Answers (1)

Hunter McMillen
Hunter McMillen

Reputation: 61540

You want to use the fdopen() function:

FILE * file = fdopen(fd, "r");

so you could use it in combination with pipe like this:

FILE * file = fdopen(pipe(..,..), "r");

Upvotes: 3

Related Questions