Module sys

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.

Description

This module implements a strict subset of the Erlang/OTP sys interface.

Data Types

dbg_opt()

abstract datatype: dbg_opt()

debug_option()


debug_option() = trace

format_fun()


format_fun() = fun((standard_io, Event::any(), Extra::system_event()) -> any())

name()


name() = pid() | atom() | {global, term()} | {via, module(), term()}

system_event()


system_event() = any()

Function Index

change_code/4Equivalent to change_code(Name, Module, OldVsn, Extra, 5000).
change_code/5Tells the process to change code.
debug_options/1Initiates debug structure with a list of options.
get_state/1Equivalent to get_state(Name, 5000).
get_state/2Gets the state of the process.
get_status/1Equivalent to get_state(Name, 5000).
get_status/2Gets the status of the process.
handle_debug/4Call FormatFunc if tracing is enabled.
handle_system_msg/6This function is used by a process module to take care of system messages.
replace_state/2Equivalent to replace_state(Name, StateFun, 5000).
replace_state/3Replaces the state of the process, and returns the new state.
resume/1Equivalent to resume(Name, 5000).
resume/2Resume a suspended process.
suspend/1Equivalent to suspend(Name, 5000).
suspend/2Suspend the process.
terminate/2Equivalent to terminate(Name, Reason, 5000).
terminate/3Terminate a process.
trace/2Equivalent to trace(Name, Flag, 5000).
trace/3Enable or disable trace on a process.

Function Details

change_code/4


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/5


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/1


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/1


get_state(Name::name()) -> any()

Equivalent to get_state(Name, 5000).

get_state/2


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/1


get_status(Name::name()) -> any()

Equivalent to get_state(Name, 5000).

get_status/2


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/4


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/6


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/2


replace_state(Name::name(), StateFun::fun((any()) -> any())) -> ok

Equivalent to replace_state(Name, StateFun, 5000).

replace_state/3


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/1


resume(Name::name()) -> ok

Equivalent to resume(Name, 5000).

resume/2


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/1


suspend(Name::name()) -> ok

Equivalent to suspend(Name, 5000).

suspend/2


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/2


terminate(Name::name(), Reason::any()) -> ok

Equivalent to terminate(Name, Reason, 5000).

terminate/3


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/2


trace(Name::name(), Flag::boolean()) -> ok

Equivalent to trace(Name, Flag, 5000).

trace/3


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.