zhh zhh - 1 year ago 76
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download