[erlang-questions] Proper way to run C code without crashing the VM
Wed Aug 16 15:58:46 CEST 2017
When the stability is important you have several choices:
1. Not use a NIF, write your logic in Erlang. Big industrial Erlang users
may prefer this, for better debuggability and predictability at the cost of
2. Write a really safe NIF which doesn't crash. Use defensive programming
approach. Use safe language like Rust.
3. Separate your C code from Erlang node, write a port — a console
application which accepts input in stdin and prints results to stdout, then
use Erlang open port function to start it and port commands to communicate
2017-08-16 15:53 GMT+02:00 code wiget <codewiget95@REDACTED>:
> I have been reading about NIF’s here: http://erlang.org/doc/
> tutorial/nif.html but it seems like they are incredibly unsafe: “it is
> also the least safe, because a crash in a NIF brings the emulator down
> too”. The problem here is huge, ideally I can’t ever have my Erlang VM
> What solution do you Erlangers use when you have to run low level code? My
> goal is to send a sort of “GET” request with a UUID and I will receive back
> that UUID along with some binary values. My C code works with this, but I
> can’t jeopardize the entire server crashing.
> Thank you for your help!
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions