erlangerlang-otp

Temporarily freeze Erlang process remotely?


Is there a way to temporarily freeze (forcefully temporaily pause execution) an erlang process remotely? So not by sending a message that the process receives and stops execution until it gets an unfreeze message, but something more invasive.

Whenever I do live reloads locally, some process ends up calling a function while it's temporarily unloaded. I'd very much like to avoid those crashes, so I thought about remotely freezing some processes, like SIGSTOP does on linux.


Solution

  • There is a suspend function which can do the trick.

    erlang:suspend_process(PidOfTheProcessToBeSuspended)
    

    you can later resume the process by calling

    erlang:resume_process(PidOfTheProcessToBeResumed)
    

    https://www.erlang.org/doc/man/erlang.html#suspend_process-1