当打开进程终止时,文件将自动关闭 [英] Will the file get automatically closed, when opening process terminates
问题描述
是的。从 file:open / 2 的文档:
返回:
{ok,IoDevice}
该文件已在请求的模式下打开。
$ d
/ p>
IoDevice
真的是处理文件的进程的pid。此过程与最初打开文件的进程相关联。如果连接了IoDevice
的任何进程终止,文件将被关闭,进程本身将被终止。
I have a process, which opens the file by using file:open. Will this file get automatically closed, when my process will terminate?
解决方案Yes. From the documentation of 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 theIoDevice
is linked terminates, the file will be closed and the process itself will be terminated.
这篇关于当打开进程终止时,文件将自动关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!