问题 I mean to use fdopen FILE *fdopen(int fd, const char *mode); In man pages, it is stated that "The mode of the stream (one of the values "r", "r+", "w", "w+", "a", "a+") must be compatible with the mode of the file descriptor." So I have to first know the mode of fd (which I guess is an int ) to choose an appropriate const char *mode for the stream. I understand I should use fcntl int fcntl(int fd, int cmd); to "manipulate file descriptor" (in the following, I quote from this official source).