main-apidocs-erlang-estdlib-sys.md
An implementation of the Erlang/OTP sys interface.
This module defines the sys behaviour.
Required callback functions: system_code_change/4, system_continue/3, system_get_state/1, system_replace_state/2, system_terminate/4.
abstract datatype : dbg_opt()
debug_option() = trace
format_fun() = fun((standard_io, Event::any(), Extra::system_event()) -> any())
name() = pid() | atom() | {global, term()} | {via, module(), term()}
system_event() = any()
| change_code/4 | Equivalent to change_code(Name, Module, OldVsn, Extra, 5000). | | change_code/5 | Tells the process to change code. | | debug_options/1 | Initiates debug structure with a list of options. | | get_state/1 | Equivalent to get_state(Name, 5000). | | get_state/2 | Gets the state of the process. | | get_status/1 | Equivalent to get_state(Name, 5000). | | get_status/2 | Gets the status of the process. | | handle_debug/4 | Call FormatFunc if tracing is enabled. | | handle_system_msg/6 | This function is used by a process module to take care of system messages. | | replace_state/2 | Equivalent to replace_state(Name, StateFun, 5000). | | replace_state/3 | Replaces the state of the process, and returns the new state. | | resume/1 | Equivalent to resume(Name, 5000). | | resume/2 | Resume a suspended process. | | suspend/1 | Equivalent to suspend(Name, 5000). | | suspend/2 | Suspend the process. | | terminate/2 | Equivalent to terminate(Name, Reason, 5000). | | terminate/3 | Terminate a process. | | trace/2 | Equivalent to trace(Name, Flag, 5000). | | trace/3 | Enable or disable trace on a process. |
change_code(Name::name(), Module::module(), OldVsn::undefined | any(), Extra::any()) -> ok | {error, any()}
Equivalent to change_code(Name, Module, OldVsn, Extra, 5000).
change_code(Name::name(), Module::module(), OldVsn::undefined | any(), Extra::any(), Timeout::timeout()) -> ok | {error, any()}
Name: process to tell to change code.
Module: callback module that should implement system_code_change/4.
OldVsn: old version
Extra: any extra term passed from the update script
Timeout: timeout for the code change
returns: ok or an error tuple
Tells the process to change code.
debug_options(X1::[Opt::debug_option()]) -> [dbg_opt()]
returns: opaque debug options to be passed to handlers.
Initiates debug structure with a list of options. The only supported option is trace.
get_state(Name::name()) -> any()
Equivalent to get_state(Name, 5000).
get_state(Name::name(), Timeout::timeout()) -> any()
Name: process to get the state of.
Timeout: timeout for getting the state
returns: the state or raises an error if an error occurred.
Gets the state of the process. This function is only meant for debugging.
get_status(Name::name()) -> any()
Equivalent to get_state(Name, 5000).
get_status(Name::name(), Timeout::timeout()) -> {status, pid(), {module, module()}, [SItem::any()]}
Name: process to get the status of.
Timeout: timeout for getting the status
returns: the status or raises an error if an error occurred.
Gets the status of the process. This function is only meant for debugging and returns raw state.
handle_debug(Debug::[dbg_opt()], FormFunc::format_fun(), Extra::any(), Event::system_event()) -> [dbg_opt()]
Debug: debug options.
FormFunc: formatting function.
Extra: extra parameter passed to formatting function.
Event: current system event
returns: new debug optinons
Call FormatFunc if tracing is enabled
handle_system_msg(Msg::any(), From::{pid(), any()}, Parent::pid(), Module::module(), Debug::[dbg_opt()], Misc::any()) -> no_return()
returns: opaque debug options to be passed to handlers.
This function is used by a process module to take care of system messages. The process receives a {system, From, Msg} message and passes Msg and From to this function. This function is meant to be tail-called and will call either:
Module:system_continue/3
Module:system_terminate/4
replace_state(Name::name(), StateFun::fun((any()) -> any())) -> ok
Equivalent to replace_state(Name, StateFun, 5000).
replace_state(Name::name(), StateFun::fun((any()) -> any()), Timeout::timeout()) -> ok
Name: process to replace the state of.
Timeout: timeout for replacing the state.
returns: the new state or raises an error if an error occurred.
Replaces the state of the process, and returns the new state. This function is only meant for debugging.
resume(Name::name()) -> ok
Equivalent to resume(Name, 5000).
resume(Name::name(), Timeout::timeout()) -> ok
Name: process to resume.
Timeout: timeout for resuming the process.
returns: ok or raises an exception if an error occurred.
Resume a suspended process.
suspend(Name::name()) -> ok
Equivalent to suspend(Name, 5000).
suspend(Name::name(), Timeout::timeout()) -> ok
Name: process to suspend.
Timeout: timeout for suspending the process.
returns: ok or raises an exception if an error occurred.
Suspend the process. When a process is suspended, it only responds to other system messages, but not to any other message.
terminate(Name::name(), Reason::any()) -> ok
Equivalent to terminate(Name, Reason, 5000).
terminate(Name::name(), Reason::any(), Timeout::timeout()) -> ok
Name: process to terminate
Reason: reason for termination
Timeout: timeout for terminating
returns: ok or raises an exception if an error occurred.
Terminate a process
trace(Name::name(), Flag::boolean()) -> ok
Equivalent to trace(Name, Flag, 5000).
trace(Name::name(), Flag::boolean(), Timeout::timeout()) -> ok
Name: process to change trace of.
Flag: whether to enable tracing or to disable it.
Timeout: timeout for changing trace state.
returns: ok or raises an exception if an error occurred.
Enable or disable trace on a process.