Will the file get automatically closed, when opening process terminates

本小妞迷上赌 提交于 2019-12-11 09:17:45

问题


I have a process, which opens the file by using file:open. Will this file get automatically closed, when my process will terminate?


回答1:


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 the IoDevice is linked terminates, the file will be closed and the process itself will be terminated.



来源:https://stackoverflow.com/questions/28066839/will-the-file-get-automatically-closed-when-opening-process-terminates

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!