[erlang-questions] Hot code replacement issues ?

Alex Feng <>
Wed Dec 14 11:28:33 CET 2016

Hi Erlangers,

I am trying to understand how hot patch upgrade is done in Erlang, I got
this piece of code from stackoverflow, but I ran into 2 issues when I
played around with it.

Issue 1)  In the piece of code, I suppose to send a message 'upgrade' to
the running process, then it will finish the upgrade. It is working fine
with "?MODULE:loop();", but if I remove the prefix ?MODULE in the code,
then the upgrade will be failed, I mean when I send message 'run' after
upgrade neither the new message nor the old message are printed.

Issue 2) I was told if I recompile and reload the updated file from shell,
then it will be done as well.
So, I did this from shell, update the source file -> compile the file ->
reload it ->send msg 'run' to the same process -> 'new version' is not
printed out.   What could be the mistake?



loop() ->
        upgrade ->
            ?MODULE:loop();                                    %%without
?MODULE, it has problem.
        run ->
            io:format("This is a new version ~n"),       %% before upgrade,
the text is  'old version'.
        _ ->

Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161214/5c343870/attachment.html>

More information about the erlang-questions mailing list