Will the file be automatically closed when the opening process is completed

I have a process that opens a file using a file: open. Will this file be automatically closed when my process is completed?

+1
erlang
source share
1 answer

Yes. From the documentation file: open / 2 :

Return:

{ok, IoDevice} 

The file was opened in the requested mode. IoDevice is a link to a file.

[...]

IoDevice really is the pid of the process that processes the file. This process is associated with the process that originally opened the file. If any process that the IoDevice connection is associated with ends, the file will be closed, and the process itself will be completed.

+3
source share

All Articles