dynamic code loading

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Wed Nov 13 11:58:55 CET 2002


Hi all,

I have a question about dynamically creating .erl files, and then
loading/running them. It seems to me that the secure way of doing it is like
in the following code:

compile(R) ->
    {ok, F} = file:open("m.erl", [write]),
    file:write(F, R),
    file:close(F),

    compile:file("m.erl"),

    code:purge(m),
    code:delete(m),
    code:purge(m),
    code:load_file(m),

    m:p().

It is always certain that there are no processes running code from module m.
When running the above from the shell, sometimes it isn't enough to only
delete and purge the code... Is this how it should be, or may it be related
to cases when m:p() crashes?

thanks in advance. regards,
Vlad



More information about the erlang-questions mailing list