Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

erlang embedded into C

Tags:

c

erlang

I'm looking to embed the Erlang VM into C code... Im familiar with ports, linkedin drivers, etc. I want the C program to start the Erlang VM, and then pass messages to Erlang processes, and have those pass messages back to C code. I dont want the erlang VM to be the one that starts first and then invokes C code occasionally. I have my reasons.
I know that this negatively affects stability guarantees given by Erlang, meaning that when the master C code crashes it will taken down the Erlang VM also, since they're running in the same process. Im willing to live with those occurrences...

is this even possible?

like image 619
deepblue Avatar asked Feb 05 '11 23:02

deepblue


2 Answers

The easiest way would be to just launch it as a separate process, and then use stdin and stdout to communicate. Just reading the docs of whatever platform you're targeting will let you know how to do that.

like image 169
eliego Avatar answered Sep 20 '22 07:09

eliego


The only sane way to do this is to load the C code from the Erlang VM, not vice versa.

It's not possible out of the box, but since you have access to the Erlang source it's clearly possible to do whatever you want if you're willing to spend a lot of time modifying the code. It's not a good use of your time to go down this path.

like image 2
YOUR ARGUMENT IS VALID Avatar answered Sep 21 '22 07:09

YOUR ARGUMENT IS VALID