The remark that it implements special process by hand made me interested, so I had a look at the code. Here are some things I spotted, I hope you don’t mind.
- you don’t handle the regular naming conventions - it would be nice to be able to pass the
nameoption like with all the Elixir’s stdlib behaviours. When you do this, there are some race conditions to consider, so I would advise looking at using the:genmodule that powers all the Erlang behaviours (it’s not documented publicly, but I saw many projects using it, I’m not sure how bad of an idea that is - but it definitely handles a lot of common scenarios). - whenever you call user module callbacks, they should be wrapped in a
tryand errors should be handled appropriately (e.g. you want to call the terminate callback in that case before dying). - it’s nice to use
:sys.handle_debugfor any messages received and sent out (or any “major” events that happen in a process) - this is really useful when things go wrong. - in the receive loop, you probably want to look for the
{:EXIT, parent, reason}message in case the user starts trapping exits in the process. The special process has to exit with the same reason as the parent in case that happens. - it looks like you don’t implement the
system_code_change/4callback - there’s an additional
format_status/2callback you can implement to control what information is returned on:sys.get_statusand:sys.get_stateused, for example, by observer.






















