当打开过程终止时,文件会自动关闭吗

Will the file get automatically closed, when opening process terminates

我有一个进程,它使用 file:open 打开文件。当我的进程终止时,此文件会自动关闭吗?

是的。来自 file:open/2 的文档:

Returns:

{ok, IoDevice}

The file has been opened in the requested mode. IoDevice is a reference to the file.

[...]

IoDevice is really the pid of the process which handles the file. This process is linked to the process which originally opened the file. If any process to which the IoDevice is linked terminates, the file will be closed and the process itself will be terminated.