Can fdopen () cause a memory leak?

I use fdopen to associate a stream with an open file.

When I close()find the file, the thread is also automatically turned off, and all current memory is returned to the OS, or do I need to know the fdopen'd file and close it in a certain way?

-Adam

+3
source share
2 answers

close()- system call. It will close the file descriptor in the kernel, but will not free the pointer and FILE resources in libc. Instead, you should use fclose () in the FILE pointer, which will also take care of closing the file descriptor.

+5
source

, , , , ( ).

/Allan

-1

Source: https://habr.com/ru/post/1696930/


All Articles