Share the same file handle between multiple Erlang processes

Hi guys,

What are the consequences of sharing the same file handle returned by calling file:open/2 with several processes?

Will they be able to safely access different parts of the file in parallel (with being blocked)?
Is there any caveat for doing this?

Many thanks

If you use a raw file handle we just pass the calls to the OS, so it will be up to the OS if it can do parallel reads/writes. You (obviously?) cannot use read/write safely, but if you use pread and pwrite I don’t see any reason why it would not work.

1 Like