There is a process in Linux (Ubuntu) that opens a file for reading but does not close it deliberately. Is the file descriptor closed by the OS automatically when the process is terminated?
My specific case is in Rails application, where I open a binary file. My web server spawns multiple Rails processes. The file is opened from a singleton in each Rails process. I need to know if this binary file is closed automatically when the Rails process is terminated.
Yes, closing all open descriptors is part of the process termination routines. You can see it at the do_exit()
function, which calls exit_files()
which also, at some point, will call close_files()
.