fdopen returns a FILE* , so you should fclose it. This will also close the underlying file descriptor.
The pclose call is intended to close the handle created with popen , the function you use to run the command and connect to it using pipes.
Calling close will close the underlying file descriptor, but unfortunately, before the file descriptor had the ability to flush its data, in other words, you are likely to lose data.
source share