Created
May 23, 2018 12:39
-
-
Save holzingk/4a96fb2413657ac5ef8e9d721a93a5a0 to your computer and use it in GitHub Desktop.
Erlang Special Process Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(special_process). | |
-export([start_link/0, | |
init/1, | |
loop/1, | |
system_continue/3, | |
system_terminate/4, | |
system_code_change/4]). | |
%% Remember to use fully qualified function calls, where you want code loading to happen. | |
start_link() -> proc_lib:start_link(?MODULE , init, [self()]). | |
init(Parent) -> | |
register(?MODULE, self()), | |
proc_lib:init_ack({ok, self()}), | |
loop(state). | |
loop(state) -> | |
receive | |
{'EXIT', Parent, Reason} -> | |
exit(Reason); | |
{system, From, Request} -> | |
sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {state}). | |
end. | |
system_continue(_Parent, _Debug, {state}) -> loop(state). | |
system_terminate(Reason, _Parent, _Debug, _State) -> exit(Reason). | |
system_code_change(State, _Module, _OldVsn, _Extra) -> {ok, State}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment