zhh zhh - 11 months ago 70
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?

Answer Source

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