I just found out (after 10 years) that I mistakenly used fclose for some popen calls running on a Windows 2008 server. It worked (that is, it didn’t crash), and I still don’t need a return code for these calls.
But I need the return code of the last popen thread, and the closure was done using pclose .
It has a strange effect of returning error code 0 (it is possible that the return code was not previously pclosed ), even if the command failed, creating a very strange error in the code, which could be disastrous because the caller believes that the command worked.
Thus, it is not only a matter of descriptor leakage, it can introduce functional errors into your code (even if the application runs for several seconds and you do not care about the descriptor leakage)
source share