If one of you want to write up the "host interface"
interface ErjangHost {
InputStream getInput();
OutputStream getOutput();
OutputStream getErr();
void system_exit();
...
}
Then I'd be glad to help you find the places in the code where it needs to be used. Perhaps there is more than the above (system properties, initial arguments, etc.)
Out of the box, Erjang can only run one Erlang VM per JVM. But if you wrap it up in a separate class loader then you could run more (I did that in my Ruby VM).
Kresten
erjang.driver.FDDriverInstance
contains the mapping from file descriptor (1,2,3) to corresponding io stream. That's the logic that is ultimately reached by erlang:port_open( ... [{fd, 1}] ...) which is how erlang reads from stdin.
The logic in there is not very good because System.in is not async, and so there needs to be a thread that reads and passes things on to erjang as a message. If you have a better environment (Java7/NIO2) then we could make those async too; or if you have a way to feed the I/O to erjang piecemeal rather than on a blocking InputStream.
I can see I already did some of the generic work, look for ERT.set_stdio ... perhaps you should try to make that work.
As for shutting everything down, ... you should be able to just issue an init:stop() and that should do it (which is what ERT#shutdown does). erlang:halt() is supposed to be abrupt ... but perhaps you can make erjang.m.erlang.ErlProc#halt which is the erlang:halt BIF just do ERT.shutdown when running in embedded mode? Or perhaps there is an option in Kilim to shut it down, ... I'm not sure. Don't have time to investigate that right now. We might need some extra logic to clean up async threads...
Kresten