zhh zhh - 4 months ago 38
Linux Question

What if I don't call close(fd) function?

I use 'open' function to open a file, than I get a file descriptor 'fd', what if I don't call close(fd) before exiting my process?
Will the reference count of that file never become 0 and the space for that file never deallocate?


It will be closed by kernel properly. The reference count will be decreased and nothing will be leaked.