<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- erlang</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/erts-5.9.3.1.pdf">PDF</a><br><a href="../../../doc/index.html">Top</a></small><p><strong>Erlang Run-Time System Application (ERTS)</strong><br><strong>Reference Manual</strong><br><small>Version 5.9.3.1</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li id="no" title="erl_prim_loader " expanded="false">erl_prim_loader<ul> <li><a href="erl_prim_loader.html"> Top of manual page </a></li> <li title="start-3"><a href="erl_prim_loader.html#start-3">start/3</a></li> <li title="get_file-1"><a href="erl_prim_loader.html#get_file-1">get_file/1</a></li> <li title="get_path-0"><a href="erl_prim_loader.html#get_path-0">get_path/0</a></li> <li title="list_dir-1"><a href="erl_prim_loader.html#list_dir-1">list_dir/1</a></li> <li title="read_file_info-1"><a href="erl_prim_loader.html#read_file_info-1">read_file_info/1</a></li> <li title="set_path-1"><a href="erl_prim_loader.html#set_path-1">set_path/1</a></li> </ul> </li> <li id="loadscrollpos" title="erlang " expanded="true">erlang<ul> <li><a href="erlang.html"> Top of manual page </a></li> <li title="abs-1"><a href="erlang.html#abs-1">abs/1</a></li> <li title="adler32-1"><a href="erlang.html#adler32-1">adler32/1</a></li> <li title="adler32-2"><a href="erlang.html#adler32-2">adler32/2</a></li> <li title="adler32_combine-3"><a href="erlang.html#adler32_combine-3">adler32_combine/3</a></li> <li title="append_element-2"><a href="erlang.html#append_element-2">append_element/2</a></li> <li title="apply-2"><a href="erlang.html#apply-2">apply/2</a></li> <li title="apply-3"><a href="erlang.html#apply-3">apply/3</a></li> <li title="atom_to_binary-2"><a href="erlang.html#atom_to_binary-2">atom_to_binary/2</a></li> <li title="atom_to_list-1"><a href="erlang.html#atom_to_list-1">atom_to_list/1</a></li> <li title="binary_part-2"><a href="erlang.html#binary_part-2">binary_part/2</a></li> <li title="binary_part-3"><a href="erlang.html#binary_part-3">binary_part/3</a></li> <li title="binary_to_atom-2"><a href="erlang.html#binary_to_atom-2">binary_to_atom/2</a></li> <li title="binary_to_existing_atom-2"><a href="erlang.html#binary_to_existing_atom-2">binary_to_existing_atom/2</a></li> <li title="binary_to_list-1"><a href="erlang.html#binary_to_list-1">binary_to_list/1</a></li> <li title="binary_to_list-3"><a href="erlang.html#binary_to_list-3">binary_to_list/3</a></li> <li title="bitstring_to_list-1"><a href="erlang.html#bitstring_to_list-1">bitstring_to_list/1</a></li> <li title="binary_to_term-1"><a href="erlang.html#binary_to_term-1">binary_to_term/1</a></li> <li title="binary_to_term-2"><a href="erlang.html#binary_to_term-2">binary_to_term/2</a></li> <li title="bit_size-1"><a href="erlang.html#bit_size-1">bit_size/1</a></li> <li title="bump_reductions-1"><a href="erlang.html#bump_reductions-1">bump_reductions/1</a></li> <li title="byte_size-1"><a href="erlang.html#byte_size-1">byte_size/1</a></li> <li title="cancel_timer-1"><a href="erlang.html#cancel_timer-1">cancel_timer/1</a></li> <li title="check_old_code-1"><a href="erlang.html#check_old_code-1">check_old_code/1</a></li> <li title="check_process_code-2"><a href="erlang.html#check_process_code-2">check_process_code/2</a></li> <li title="crc32-1"><a href="erlang.html#crc32-1">crc32/1</a></li> <li title="crc32-2"><a href="erlang.html#crc32-2">crc32/2</a></li> <li title="crc32_combine-3"><a href="erlang.html#crc32_combine-3">crc32_combine/3</a></li> <li title="date-0"><a href="erlang.html#date-0">date/0</a></li> <li title="decode_packet-3"><a href="erlang.html#decode_packet-3">decode_packet/3</a></li> <li title="delete_module-1"><a href="erlang.html#delete_module-1">delete_module/1</a></li> <li title="demonitor-1"><a href="erlang.html#demonitor-1">demonitor/1</a></li> <li title="demonitor-2"><a href="erlang.html#demonitor-2">demonitor/2</a></li> <li title="disconnect_node-1"><a href="erlang.html#disconnect_node-1">disconnect_node/1</a></li> <li title="display-1"><a href="erlang.html#display-1">display/1</a></li> <li title="element-2"><a href="erlang.html#element-2">element/2</a></li> <li title="erase-0"><a href="erlang.html#erase-0">erase/0</a></li> <li title="erase-1"><a href="erlang.html#erase-1">erase/1</a></li> <li title="error-1"><a href="erlang.html#error-1">error/1</a></li> <li title="error-2"><a href="erlang.html#error-2">error/2</a></li> <li title="exit-1"><a href="erlang.html#exit-1">exit/1</a></li> <li title="exit-2"><a href="erlang.html#exit-2">exit/2</a></li> <li title="external_size-1"><a href="erlang.html#external_size-1">external_size/1</a></li> <li title="external_size-2"><a href="erlang.html#external_size-2">external_size/2</a></li> <li title="float-1"><a href="erlang.html#float-1">float/1</a></li> <li title="float_to_list-1"><a href="erlang.html#float_to_list-1">float_to_list/1</a></li> <li title="fun_info-1"><a href="erlang.html#fun_info-1">fun_info/1</a></li> <li title="fun_info-2"><a href="erlang.html#fun_info-2">fun_info/2</a></li> <li title="fun_to_list-1"><a href="erlang.html#fun_to_list-1">fun_to_list/1</a></li> <li title="function_exported-3"><a href="erlang.html#function_exported-3">function_exported/3</a></li> <li title="garbage_collect-0"><a href="erlang.html#garbage_collect-0">garbage_collect/0</a></li> <li title="garbage_collect-1"><a href="erlang.html#garbage_collect-1">garbage_collect/1</a></li> <li title="get-0"><a href="erlang.html#get-0">get/0</a></li> <li title="get-1"><a href="erlang.html#get-1">get/1</a></li> <li title="get_cookie-0"><a href="erlang.html#get_cookie-0">get_cookie/0</a></li> <li title="get_keys-1"><a href="erlang.html#get_keys-1">get_keys/1</a></li> <li title="get_stacktrace-0"><a href="erlang.html#get_stacktrace-0">get_stacktrace/0</a></li> <li title="group_leader-0"><a href="erlang.html#group_leader-0">group_leader/0</a></li> <li title="group_leader-2"><a href="erlang.html#group_leader-2">group_leader/2</a></li> <li title="halt-0"><a href="erlang.html#halt-0">halt/0</a></li> <li title="halt-1"><a href="erlang.html#halt-1">halt/1</a></li> <li title="halt-2"><a href="erlang.html#halt-2">halt/2</a></li> <li title="hash-2"><a href="erlang.html#hash-2">hash/2</a></li> <li title="hd-1"><a href="erlang.html#hd-1">hd/1</a></li> <li title="hibernate-3"><a href="erlang.html#hibernate-3">hibernate/3</a></li> <li title="integer_to_list-1"><a href="erlang.html#integer_to_list-1">integer_to_list/1</a></li> <li title="integer_to_list-2"><a href="erlang.html#integer_to_list-2">integer_to_list/2</a></li> <li title="iolist_to_binary-1"><a href="erlang.html#iolist_to_binary-1">iolist_to_binary/1</a></li> <li title="iolist_size-1"><a href="erlang.html#iolist_size-1">iolist_size/1</a></li> <li title="is_alive-0"><a href="erlang.html#is_alive-0">is_alive/0</a></li> <li title="is_atom-1"><a href="erlang.html#is_atom-1">is_atom/1</a></li> <li title="is_binary-1"><a href="erlang.html#is_binary-1">is_binary/1</a></li> <li title="is_bitstring-1"><a href="erlang.html#is_bitstring-1">is_bitstring/1</a></li> <li title="is_boolean-1"><a href="erlang.html#is_boolean-1">is_boolean/1</a></li> <li title="is_builtin-3"><a href="erlang.html#is_builtin-3">is_builtin/3</a></li> <li title="is_float-1"><a href="erlang.html#is_float-1">is_float/1</a></li> <li title="is_function-1"><a href="erlang.html#is_function-1">is_function/1</a></li> <li title="is_function-2"><a href="erlang.html#is_function-2">is_function/2</a></li> <li title="is_integer-1"><a href="erlang.html#is_integer-1">is_integer/1</a></li> <li title="is_list-1"><a href="erlang.html#is_list-1">is_list/1</a></li> <li title="is_number-1"><a href="erlang.html#is_number-1">is_number/1</a></li> <li title="is_pid-1"><a href="erlang.html#is_pid-1">is_pid/1</a></li> <li title="is_port-1"><a href="erlang.html#is_port-1">is_port/1</a></li> <li title="is_process_alive-1"><a href="erlang.html#is_process_alive-1">is_process_alive/1</a></li> <li title="is_record-2"><a href="erlang.html#is_record-2">is_record/2</a></li> <li title="is_record-3"><a href="erlang.html#is_record-3">is_record/3</a></li> <li title="is_reference-1"><a href="erlang.html#is_reference-1">is_reference/1</a></li> <li title="is_tuple-1"><a href="erlang.html#is_tuple-1">is_tuple/1</a></li> <li title="length-1"><a href="erlang.html#length-1">length/1</a></li> <li title="link-1"><a href="erlang.html#link-1">link/1</a></li> <li title="list_to_atom-1"><a href="erlang.html#list_to_atom-1">list_to_atom/1</a></li> <li title="list_to_binary-1"><a href="erlang.html#list_to_binary-1">list_to_binary/1</a></li> <li title="list_to_bitstring-1"><a href="erlang.html#list_to_bitstring-1">list_to_bitstring/1</a></li> <li title="list_to_existing_atom-1"><a href="erlang.html#list_to_existing_atom-1">list_to_existing_atom/1</a></li> <li title="list_to_float-1"><a href="erlang.html#list_to_float-1">list_to_float/1</a></li> <li title="list_to_integer-1"><a href="erlang.html#list_to_integer-1">list_to_integer/1</a></li> <li title="list_to_integer-2"><a href="erlang.html#list_to_integer-2">list_to_integer/2</a></li> <li title="list_to_pid-1"><a href="erlang.html#list_to_pid-1">list_to_pid/1</a></li> <li title="list_to_tuple-1"><a href="erlang.html#list_to_tuple-1">list_to_tuple/1</a></li> <li title="load_module-2"><a href="erlang.html#load_module-2">load_module/2</a></li> <li title="load_nif-2"><a href="erlang.html#load_nif-2">load_nif/2</a></li> <li title="loaded-0"><a href="erlang.html#loaded-0">loaded/0</a></li> <li title="localtime-0"><a href="erlang.html#localtime-0">localtime/0</a></li> <li title="localtime_to_universaltime-1"><a href="erlang.html#localtime_to_universaltime-1">localtime_to_universaltime/1</a></li> <li title="localtime_to_universaltime-2"><a href="erlang.html#localtime_to_universaltime-2">localtime_to_universaltime/2</a></li> <li title="make_ref-0"><a href="erlang.html#make_ref-0">make_ref/0</a></li> <li title="make_tuple-2"><a href="erlang.html#make_tuple-2">make_tuple/2</a></li> <li title="make_tuple-3"><a href="erlang.html#make_tuple-3">make_tuple/3</a></li> <li title="max-2"><a href="erlang.html#max-2">max/2</a></li> <li title="md5-1"><a href="erlang.html#md5-1">md5/1</a></li> <li title="md5_final-1"><a href="erlang.html#md5_final-1">md5_final/1</a></li> <li title="md5_init-0"><a href="erlang.html#md5_init-0">md5_init/0</a></li> <li title="md5_update-2"><a href="erlang.html#md5_update-2">md5_update/2</a></li> <li title="memory-0"><a href="erlang.html#memory-0">memory/0</a></li> <li title="memory-1"><a href="erlang.html#memory-1">memory/1</a></li> <li title="min-2"><a href="erlang.html#min-2">min/2</a></li> <li title="module_loaded-1"><a href="erlang.html#module_loaded-1">module_loaded/1</a></li> <li title="monitor-2"><a href="erlang.html#monitor-2">monitor/2</a></li> <li title="monitor_node-2"><a href="erlang.html#monitor_node-2">monitor_node/2</a></li> <li title="monitor_node-3"><a href="erlang.html#monitor_node-3">monitor_node/3</a></li> <li title="nif_error-1"><a href="erlang.html#nif_error-1">nif_error/1</a></li> <li title="nif_error-2"><a href="erlang.html#nif_error-2">nif_error/2</a></li> <li title="node-0"><a href="erlang.html#node-0">node/0</a></li> <li title="node-1"><a href="erlang.html#node-1">node/1</a></li> <li title="nodes-0"><a href="erlang.html#nodes-0">nodes/0</a></li> <li title="nodes-1"><a href="erlang.html#nodes-1">nodes/1</a></li> <li title="now-0"><a href="erlang.html#now-0">now/0</a></li> <li title="open_port-2"><a href="erlang.html#open_port-2">open_port/2</a></li> <li title="phash-2"><a href="erlang.html#phash-2">phash/2</a></li> <li title="phash2-1"><a href="erlang.html#phash2-1">phash2/1</a></li> <li title="pid_to_list-1"><a href="erlang.html#pid_to_list-1">pid_to_list/1</a></li> <li title="port_close-1"><a href="erlang.html#port_close-1">port_close/1</a></li> <li title="port_command-2"><a href="erlang.html#port_command-2">port_command/2</a></li> <li title="port_command-3"><a href="erlang.html#port_command-3">port_command/3</a></li> <li title="port_connect-2"><a href="erlang.html#port_connect-2">port_connect/2</a></li> <li title="port_control-3"><a href="erlang.html#port_control-3">port_control/3</a></li> <li title="port_call-3"><a href="erlang.html#port_call-3">port_call/3</a></li> <li title="port_info-1"><a href="erlang.html#port_info-1">port_info/1</a></li> <li title="port_info-2"><a href="erlang.html#port_info-2">port_info/2</a></li> <li title="port_to_list-1"><a href="erlang.html#port_to_list-1">port_to_list/1</a></li> <li title="ports-0"><a href="erlang.html#ports-0">ports/0</a></li> <li title="pre_loaded-0"><a href="erlang.html#pre_loaded-0">pre_loaded/0</a></li> <li title="process_display-2"><a href="erlang.html#process_display-2">process_display/2</a></li> <li title="process_flag-2"><a href="erlang.html#process_flag-2">process_flag/2</a></li> <li title="process_flag-3"><a href="erlang.html#process_flag-3">process_flag/3</a></li> <li title="process_info-1"><a href="erlang.html#process_info-1">process_info/1</a></li> <li title="process_info-2"><a href="erlang.html#process_info-2">process_info/2</a></li> <li title="processes-0"><a href="erlang.html#processes-0">processes/0</a></li> <li title="purge_module-1"><a href="erlang.html#purge_module-1">purge_module/1</a></li> <li title="put-2"><a href="erlang.html#put-2">put/2</a></li> <li title="raise-3"><a href="erlang.html#raise-3">raise/3</a></li> <li title="read_timer-1"><a href="erlang.html#read_timer-1">read_timer/1</a></li> <li title="ref_to_list-1"><a href="erlang.html#ref_to_list-1">ref_to_list/1</a></li> <li title="register-2"><a href="erlang.html#register-2">register/2</a></li> <li title="registered-0"><a href="erlang.html#registered-0">registered/0</a></li> <li title="resume_process-1"><a href="erlang.html#resume_process-1">resume_process/1</a></li> <li title="round-1"><a href="erlang.html#round-1">round/1</a></li> <li title="self-0"><a href="erlang.html#self-0">self/0</a></li> <li title="send-2"><a href="erlang.html#send-2">send/2</a></li> <li title="send-3"><a href="erlang.html#send-3">send/3</a></li> <li title="send_after-3"><a href="erlang.html#send_after-3">send_after/3</a></li> <li title="send_nosuspend-2"><a href="erlang.html#send_nosuspend-2">send_nosuspend/2</a></li> <li title="send_nosuspend-3"><a href="erlang.html#send_nosuspend-3">send_nosuspend/3</a></li> <li title="set_cookie-2"><a href="erlang.html#set_cookie-2">set_cookie/2</a></li> <li title="setelement-3"><a href="erlang.html#setelement-3">setelement/3</a></li> <li title="size-1"><a href="erlang.html#size-1">size/1</a></li> <li title="spawn-1"><a href="erlang.html#spawn-1">spawn/1</a></li> <li title="spawn-2"><a href="erlang.html#spawn-2">spawn/2</a></li> <li title="spawn-3"><a href="erlang.html#spawn-3">spawn/3</a></li> <li title="spawn-4"><a href="erlang.html#spawn-4">spawn/4</a></li> <li title="spawn_link-1"><a href="erlang.html#spawn_link-1">spawn_link/1</a></li> <li title="spawn_link-2"><a href="erlang.html#spawn_link-2">spawn_link/2</a></li> <li title="spawn_link-3"><a href="erlang.html#spawn_link-3">spawn_link/3</a></li> <li title="spawn_link-4"><a href="erlang.html#spawn_link-4">spawn_link/4</a></li> <li title="spawn_monitor-1"><a href="erlang.html#spawn_monitor-1">spawn_monitor/1</a></li> <li title="spawn_monitor-3"><a href="erlang.html#spawn_monitor-3">spawn_monitor/3</a></li> <li title="spawn_opt-2"><a href="erlang.html#spawn_opt-2">spawn_opt/2</a></li> <li title="spawn_opt-3"><a href="erlang.html#spawn_opt-3">spawn_opt/3</a></li> <li title="spawn_opt-4"><a href="erlang.html#spawn_opt-4">spawn_opt/4</a></li> <li title="spawn_opt-5"><a href="erlang.html#spawn_opt-5">spawn_opt/5</a></li> <li title="split_binary-2"><a href="erlang.html#split_binary-2">split_binary/2</a></li> <li title="start_timer-3"><a href="erlang.html#start_timer-3">start_timer/3</a></li> <li title="statistics-1"><a href="erlang.html#statistics-1">statistics/1</a></li> <li title="suspend_process-2"><a href="erlang.html#suspend_process-2">suspend_process/2</a></li> <li title="suspend_process-1"><a href="erlang.html#suspend_process-1">suspend_process/1</a></li> <li title="system_flag-2"><a href="erlang.html#system_flag-2">system_flag/2</a></li> <li title="system_info-1"><a href="erlang.html#system_info-1">system_info/1</a></li> <li title="system_monitor-0"><a href="erlang.html#system_monitor-0">system_monitor/0</a></li> <li title="system_monitor-1"><a href="erlang.html#system_monitor-1">system_monitor/1</a></li> <li title="system_monitor-2"><a href="erlang.html#system_monitor-2">system_monitor/2</a></li> <li title="system_profile-0"><a href="erlang.html#system_profile-0">system_profile/0</a></li> <li title="system_profile-2"><a href="erlang.html#system_profile-2">system_profile/2</a></li> <li title="term_to_binary-1"><a href="erlang.html#term_to_binary-1">term_to_binary/1</a></li> <li title="term_to_binary-2"><a href="erlang.html#term_to_binary-2">term_to_binary/2</a></li> <li title="throw-1"><a href="erlang.html#throw-1">throw/1</a></li> <li title="time-0"><a href="erlang.html#time-0">time/0</a></li> <li title="tl-1"><a href="erlang.html#tl-1">tl/1</a></li> <li title="trace-3"><a href="erlang.html#trace-3">trace/3</a></li> <li title="trace_delivered-1"><a href="erlang.html#trace_delivered-1">trace_delivered/1</a></li> <li title="trace_info-2"><a href="erlang.html#trace_info-2">trace_info/2</a></li> <li title="trace_pattern-2"><a href="erlang.html#trace_pattern-2">trace_pattern/2</a></li> <li title="trace_pattern-3"><a href="erlang.html#trace_pattern-3">trace_pattern/3</a></li> <li title="trunc-1"><a href="erlang.html#trunc-1">trunc/1</a></li> <li title="tuple_size-1"><a href="erlang.html#tuple_size-1">tuple_size/1</a></li> <li title="tuple_to_list-1"><a href="erlang.html#tuple_to_list-1">tuple_to_list/1</a></li> <li title="universaltime-0"><a href="erlang.html#universaltime-0">universaltime/0</a></li> <li title="universaltime_to_localtime-1"><a href="erlang.html#universaltime_to_localtime-1">universaltime_to_localtime/1</a></li> <li title="unlink-1"><a href="erlang.html#unlink-1">unlink/1</a></li> <li title="unregister-1"><a href="erlang.html#unregister-1">unregister/1</a></li> <li title="whereis-1"><a href="erlang.html#whereis-1">whereis/1</a></li> <li title="yield-0"><a href="erlang.html#yield-0">yield/0</a></li> </ul> </li> <li id="no" title="init " expanded="false">init<ul> <li><a href="init.html"> Top of manual page </a></li> <li title="boot-1"><a href="init.html#boot-1">boot/1</a></li> <li title="get_argument-1"><a href="init.html#get_argument-1">get_argument/1</a></li> <li title="get_arguments-0"><a href="init.html#get_arguments-0">get_arguments/0</a></li> <li title="get_plain_arguments-0"><a href="init.html#get_plain_arguments-0">get_plain_arguments/0</a></li> <li title="get_status-0"><a href="init.html#get_status-0">get_status/0</a></li> <li title="reboot-0"><a href="init.html#reboot-0">reboot/0</a></li> <li title="restart-0"><a href="init.html#restart-0">restart/0</a></li> <li title="script_id-0"><a href="init.html#script_id-0">script_id/0</a></li> <li title="stop-0"><a href="init.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="init.html#stop-1">stop/1</a></li> </ul> </li> <li id="no" title="zlib " expanded="false">zlib<ul> <li><a href="zlib.html"> Top of manual page </a></li> <li title="open-0"><a href="zlib.html#open-0">open/0</a></li> <li title="close-1"><a href="zlib.html#close-1">close/1</a></li> <li title="deflateInit-1"><a href="zlib.html#deflateInit-1">deflateInit/1</a></li> <li title="deflateInit-2"><a href="zlib.html#deflateInit-2">deflateInit/2</a></li> <li title="deflateInit-6"><a href="zlib.html#deflateInit-6">deflateInit/6</a></li> <li title="deflate-2"><a href="zlib.html#deflate-2">deflate/2</a></li> <li title="deflate-3"><a href="zlib.html#deflate-3">deflate/3</a></li> <li title="deflateSetDictionary-2"><a href="zlib.html#deflateSetDictionary-2">deflateSetDictionary/2</a></li> <li title="deflateReset-1"><a href="zlib.html#deflateReset-1">deflateReset/1</a></li> <li title="deflateParams-3"><a href="zlib.html#deflateParams-3">deflateParams/3</a></li> <li title="deflateEnd-1"><a href="zlib.html#deflateEnd-1">deflateEnd/1</a></li> <li title="inflateInit-1"><a href="zlib.html#inflateInit-1">inflateInit/1</a></li> <li title="inflateInit-2"><a href="zlib.html#inflateInit-2">inflateInit/2</a></li> <li title="inflate-2"><a href="zlib.html#inflate-2">inflate/2</a></li> <li title="inflateSetDictionary-2"><a href="zlib.html#inflateSetDictionary-2">inflateSetDictionary/2</a></li> <li title="inflateReset-1"><a href="zlib.html#inflateReset-1">inflateReset/1</a></li> <li title="inflateEnd-1"><a href="zlib.html#inflateEnd-1">inflateEnd/1</a></li> <li title="setBufSize-2"><a href="zlib.html#setBufSize-2">setBufSize/2</a></li> <li title="getBufSize-1"><a href="zlib.html#getBufSize-1">getBufSize/1</a></li> <li title="crc32-1"><a href="zlib.html#crc32-1">crc32/1</a></li> <li title="crc32-2"><a href="zlib.html#crc32-2">crc32/2</a></li> <li title="crc32-3"><a href="zlib.html#crc32-3">crc32/3</a></li> <li title="crc32_combine-4"><a href="zlib.html#crc32_combine-4">crc32_combine/4</a></li> <li title="adler32-2"><a href="zlib.html#adler32-2">adler32/2</a></li> <li title="adler32-3"><a href="zlib.html#adler32-3">adler32/3</a></li> <li title="adler32_combine-4"><a href="zlib.html#adler32_combine-4">adler32_combine/4</a></li> <li title="compress-1"><a href="zlib.html#compress-1">compress/1</a></li> <li title="uncompress-1"><a href="zlib.html#uncompress-1">uncompress/1</a></li> <li title="zip-1"><a href="zlib.html#zip-1">zip/1</a></li> <li title="unzip-1"><a href="zlib.html#unzip-1">unzip/1</a></li> <li title="gzip-1"><a href="zlib.html#gzip-1">gzip/1</a></li> <li title="gunzip-1"><a href="zlib.html#gunzip-1">gunzip/1</a></li> </ul> </li> <li title="epmd"><a href="epmd.html">epmd</a></li> <li title="erl"><a href="erl.html">erl</a></li> <li title="erlc"><a href="erlc.html">erlc</a></li> <li title="werl"><a href="werl.html">werl</a></li> <li title="escript"><a href="escript.html">escript</a></li> <li title="erlsrv"><a href="erlsrv.html">erlsrv</a></li> <li title="start_erl"><a href="start_erl.html">start_erl</a></li> <li id="no" title="erl_set_memory_block " expanded="false">erl_set_memory_block<ul> <li><a href="erl_set_memory_block.html"> Top of manual page </a></li> <li title="erl_set_memory_block"><a href="erl_set_memory_block.html#erl_set_memory_block">erl_set_memory_block() </a></li> <li title="erl_memory_show"><a href="erl_set_memory_block.html#erl_memory_show">erl_memory_show() </a></li> <li title="erl_mem_info_get"><a href="erl_set_memory_block.html#erl_mem_info_get">erl_mem_info_get() </a></li> </ul> </li> <li title="run_erl"><a href="run_erl.html">run_erl</a></li> <li title="start"><a href="start.html">start</a></li> <li id="no" title="erl_driver " expanded="false">erl_driver<ul> <li><a href="erl_driver.html"> Top of manual page </a></li> <li title="driver_system_info"><a href="erl_driver.html#driver_system_info">driver_system_info() </a></li> <li title="driver_output"><a href="erl_driver.html#driver_output">driver_output() </a></li> <li title="driver_output2"><a href="erl_driver.html#driver_output2">driver_output2() </a></li> <li title="driver_output_binary"><a href="erl_driver.html#driver_output_binary">driver_output_binary() </a></li> <li title="driver_outputv"><a href="erl_driver.html#driver_outputv">driver_outputv() </a></li> <li title="driver_vec_to_buf"><a href="erl_driver.html#driver_vec_to_buf">driver_vec_to_buf() </a></li> <li title="driver_set_timer"><a href="erl_driver.html#driver_set_timer">driver_set_timer() </a></li> <li title="driver_cancel_timer"><a href="erl_driver.html#driver_cancel_timer">driver_cancel_timer() </a></li> <li title="driver_read_timer"><a href="erl_driver.html#driver_read_timer">driver_read_timer() </a></li> <li title="driver_get_now"><a href="erl_driver.html#driver_get_now">driver_get_now() </a></li> <li title="driver_select"><a href="erl_driver.html#driver_select">driver_select() </a></li> <li title="driver_alloc"><a href="erl_driver.html#driver_alloc">driver_alloc() </a></li> <li title="driver_realloc"><a href="erl_driver.html#driver_realloc">driver_realloc() </a></li> <li title="driver_free"><a href="erl_driver.html#driver_free">driver_free() </a></li> <li title="driver_alloc_binary"><a href="erl_driver.html#driver_alloc_binary">driver_alloc_binary() </a></li> <li title="driver_realloc_binary"><a href="erl_driver.html#driver_realloc_binary">driver_realloc_binary() </a></li> <li title="driver_free_binary"><a href="erl_driver.html#driver_free_binary">driver_free_binary() </a></li> <li title="driver_binary_get_refc"><a href="erl_driver.html#driver_binary_get_refc">driver_binary_get_refc() </a></li> <li title="driver_binary_inc_refc"><a href="erl_driver.html#driver_binary_inc_refc">driver_binary_inc_refc() </a></li> <li title="driver_binary_dec_refc"><a href="erl_driver.html#driver_binary_dec_refc">driver_binary_dec_refc() </a></li> <li title="driver_enq"><a href="erl_driver.html#driver_enq">driver_enq() </a></li> <li title="driver_pushq"><a href="erl_driver.html#driver_pushq">driver_pushq() </a></li> <li title="driver_deq"><a href="erl_driver.html#driver_deq">driver_deq() </a></li> <li title="driver_sizeq"><a href="erl_driver.html#driver_sizeq">driver_sizeq() </a></li> <li title="driver_enq_bin"><a href="erl_driver.html#driver_enq_bin">driver_enq_bin() </a></li> <li title="driver_pushq_bin"><a href="erl_driver.html#driver_pushq_bin">driver_pushq_bin() </a></li> <li title="driver_peekqv"><a href="erl_driver.html#driver_peekqv">driver_peekqv() </a></li> <li title="driver_peekq"><a href="erl_driver.html#driver_peekq">driver_peekq() </a></li> <li title="driver_enqv"><a href="erl_driver.html#driver_enqv">driver_enqv() </a></li> <li title="driver_pushqv"><a href="erl_driver.html#driver_pushqv">driver_pushqv() </a></li> <li title="driver_pdl_create"><a href="erl_driver.html#driver_pdl_create">driver_pdl_create() </a></li> <li title="driver_pdl_lock"><a href="erl_driver.html#driver_pdl_lock">driver_pdl_lock() </a></li> <li title="driver_pdl_unlock"><a href="erl_driver.html#driver_pdl_unlock">driver_pdl_unlock() </a></li> <li title="driver_pdl_get_refc"><a href="erl_driver.html#driver_pdl_get_refc">driver_pdl_get_refc() </a></li> <li title="driver_pdl_inc_refc"><a href="erl_driver.html#driver_pdl_inc_refc">driver_pdl_inc_refc() </a></li> <li title="driver_pdl_dec_refc"><a href="erl_driver.html#driver_pdl_dec_refc">driver_pdl_dec_refc() </a></li> <li title="driver_monitor_process"><a href="erl_driver.html#driver_monitor_process">driver_monitor_process() </a></li> <li title="driver_demonitor_process"><a href="erl_driver.html#driver_demonitor_process">driver_demonitor_process() </a></li> <li title="driver_get_monitored_process"><a href="erl_driver.html#driver_get_monitored_process">driver_get_monitored_process() </a></li> <li title="driver_compare_monitors"><a href="erl_driver.html#driver_compare_monitors">driver_compare_monitors() </a></li> <li title="add_driver_entry"><a href="erl_driver.html#add_driver_entry">add_driver_entry() </a></li> <li title="remove_driver_entry"><a href="erl_driver.html#remove_driver_entry">remove_driver_entry() </a></li> <li title="erl_errno_id"><a href="erl_driver.html#erl_errno_id">erl_errno_id() </a></li> <li title="set_busy_port"><a href="erl_driver.html#set_busy_port">set_busy_port() </a></li> <li title="set_port_control_flags"><a href="erl_driver.html#set_port_control_flags">set_port_control_flags() </a></li> <li title="driver_failure_eof"><a href="erl_driver.html#driver_failure_eof">driver_failure_eof() </a></li> <li title="driver_failure_atom"><a href="erl_driver.html#driver_failure_atom">driver_failure_atom() </a></li> <li title="driver_failure_posix"><a href="erl_driver.html#driver_failure_posix">driver_failure_posix() </a></li> <li title="driver_failure"><a href="erl_driver.html#driver_failure">driver_failure() </a></li> <li title="driver_connected"><a href="erl_driver.html#driver_connected">driver_connected() </a></li> <li title="driver_caller"><a href="erl_driver.html#driver_caller">driver_caller() </a></li> <li title="driver_output_term"><a href="erl_driver.html#driver_output_term">driver_output_term() </a></li> <li title="driver_mk_atom"><a href="erl_driver.html#driver_mk_atom">driver_mk_atom() </a></li> <li title="driver_mk_port"><a href="erl_driver.html#driver_mk_port">driver_mk_port() </a></li> <li title="driver_send_term"><a href="erl_driver.html#driver_send_term">driver_send_term() </a></li> <li title="driver_async "><a href="erl_driver.html#driver_async%20">driver_async () </a></li> <li title="driver_async_cancel"><a href="erl_driver.html#driver_async_cancel">driver_async_cancel() </a></li> <li title="driver_lock_driver"><a href="erl_driver.html#driver_lock_driver">driver_lock_driver() </a></li> <li title="driver_create_port"><a href="erl_driver.html#driver_create_port">driver_create_port() </a></li> <li title="erl_drv_thread_create"><a href="erl_driver.html#erl_drv_thread_create">erl_drv_thread_create() </a></li> <li title="erl_drv_thread_opts_create"><a href="erl_driver.html#erl_drv_thread_opts_create">erl_drv_thread_opts_create() </a></li> <li title="erl_drv_thread_opts_destroy"><a href="erl_driver.html#erl_drv_thread_opts_destroy">erl_drv_thread_opts_destroy() </a></li> <li title="erl_drv_thread_exit"><a href="erl_driver.html#erl_drv_thread_exit">erl_drv_thread_exit() </a></li> <li title="erl_drv_thread_join"><a href="erl_driver.html#erl_drv_thread_join">erl_drv_thread_join() </a></li> <li title="erl_drv_thread_self"><a href="erl_driver.html#erl_drv_thread_self">erl_drv_thread_self() </a></li> <li title="erl_drv_equal_tids"><a href="erl_driver.html#erl_drv_equal_tids">erl_drv_equal_tids() </a></li> <li title="erl_drv_mutex_create"><a href="erl_driver.html#erl_drv_mutex_create">erl_drv_mutex_create() </a></li> <li title="erl_drv_mutex_destroy"><a href="erl_driver.html#erl_drv_mutex_destroy">erl_drv_mutex_destroy() </a></li> <li title="erl_drv_mutex_lock"><a href="erl_driver.html#erl_drv_mutex_lock">erl_drv_mutex_lock() </a></li> <li title="erl_drv_mutex_trylock"><a href="erl_driver.html#erl_drv_mutex_trylock">erl_drv_mutex_trylock() </a></li> <li title="erl_drv_mutex_unlock"><a href="erl_driver.html#erl_drv_mutex_unlock">erl_drv_mutex_unlock() </a></li> <li title="erl_drv_cond_create"><a href="erl_driver.html#erl_drv_cond_create">erl_drv_cond_create() </a></li> <li title="erl_drv_cond_destroy"><a href="erl_driver.html#erl_drv_cond_destroy">erl_drv_cond_destroy() </a></li> <li title="erl_drv_cond_signal"><a href="erl_driver.html#erl_drv_cond_signal">erl_drv_cond_signal() </a></li> <li title="erl_drv_cond_broadcast"><a href="erl_driver.html#erl_drv_cond_broadcast">erl_drv_cond_broadcast() </a></li> <li title="erl_drv_cond_wait"><a href="erl_driver.html#erl_drv_cond_wait">erl_drv_cond_wait() </a></li> <li title="erl_drv_rwlock_create"><a href="erl_driver.html#erl_drv_rwlock_create">erl_drv_rwlock_create() </a></li> <li title="erl_drv_rwlock_destroy"><a href="erl_driver.html#erl_drv_rwlock_destroy">erl_drv_rwlock_destroy() </a></li> <li title="erl_drv_rwlock_rlock"><a href="erl_driver.html#erl_drv_rwlock_rlock">erl_drv_rwlock_rlock() </a></li> <li title="erl_drv_rwlock_tryrlock"><a href="erl_driver.html#erl_drv_rwlock_tryrlock">erl_drv_rwlock_tryrlock() </a></li> <li title="erl_drv_rwlock_runlock"><a href="erl_driver.html#erl_drv_rwlock_runlock">erl_drv_rwlock_runlock() </a></li> <li title="erl_drv_rwlock_rwlock"><a href="erl_driver.html#erl_drv_rwlock_rwlock">erl_drv_rwlock_rwlock() </a></li> <li title="erl_drv_rwlock_tryrwlock"><a href="erl_driver.html#erl_drv_rwlock_tryrwlock">erl_drv_rwlock_tryrwlock() </a></li> <li title="erl_drv_rwlock_rwunlock"><a href="erl_driver.html#erl_drv_rwlock_rwunlock">erl_drv_rwlock_rwunlock() </a></li> <li title="erl_drv_tsd_key_create"><a href="erl_driver.html#erl_drv_tsd_key_create">erl_drv_tsd_key_create() </a></li> <li title="erl_drv_tsd_key_destroy"><a href="erl_driver.html#erl_drv_tsd_key_destroy">erl_drv_tsd_key_destroy() </a></li> <li title="erl_drv_tsd_set"><a href="erl_driver.html#erl_drv_tsd_set">erl_drv_tsd_set() </a></li> <li title="erl_drv_tsd_get"><a href="erl_driver.html#erl_drv_tsd_get">erl_drv_tsd_get() </a></li> <li title="erl_drv_putenv"><a href="erl_driver.html#erl_drv_putenv">erl_drv_putenv() </a></li> <li title="erl_drv_getenv"><a href="erl_driver.html#erl_drv_getenv">erl_drv_getenv() </a></li> </ul> </li> <li title="driver_entry"><a href="driver_entry.html">driver_entry</a></li> <li title="erts_alloc"><a href="erts_alloc.html">erts_alloc</a></li> <li id="no" title="erl_nif " expanded="false">erl_nif<ul> <li><a href="erl_nif.html"> Top of manual page </a></li> <li title="enif_alloc"><a href="erl_nif.html#enif_alloc">enif_alloc() </a></li> <li title="enif_alloc_binary"><a href="erl_nif.html#enif_alloc_binary">enif_alloc_binary() </a></li> <li title="enif_alloc_env"><a href="erl_nif.html#enif_alloc_env">enif_alloc_env() </a></li> <li title="enif_alloc_resource"><a href="erl_nif.html#enif_alloc_resource">enif_alloc_resource() </a></li> <li title="enif_clear_env"><a href="erl_nif.html#enif_clear_env">enif_clear_env() </a></li> <li title="enif_compare"><a href="erl_nif.html#enif_compare">enif_compare() </a></li> <li title="enif_cond_broadcast"><a href="erl_nif.html#enif_cond_broadcast">enif_cond_broadcast() </a></li> <li title="enif_cond_create"><a href="erl_nif.html#enif_cond_create">enif_cond_create() </a></li> <li title="enif_cond_destroy"><a href="erl_nif.html#enif_cond_destroy">enif_cond_destroy() </a></li> <li title="enif_cond_signal"><a href="erl_nif.html#enif_cond_signal">enif_cond_signal() </a></li> <li title="enif_cond_wait"><a href="erl_nif.html#enif_cond_wait">enif_cond_wait() </a></li> <li title="enif_equal_tids"><a href="erl_nif.html#enif_equal_tids">enif_equal_tids() </a></li> <li title="enif_free"><a href="erl_nif.html#enif_free">enif_free() </a></li> <li title="enif_free_env"><a href="erl_nif.html#enif_free_env">enif_free_env() </a></li> <li title="enif_get_atom"><a href="erl_nif.html#enif_get_atom">enif_get_atom() </a></li> <li title="enif_get_atom_length"><a href="erl_nif.html#enif_get_atom_length">enif_get_atom_length() </a></li> <li title="enif_get_double"><a href="erl_nif.html#enif_get_double">enif_get_double() </a></li> <li title="enif_get_int"><a href="erl_nif.html#enif_get_int">enif_get_int() </a></li> <li title="enif_get_int64"><a href="erl_nif.html#enif_get_int64">enif_get_int64() </a></li> <li title="enif_get_local_pid"><a href="erl_nif.html#enif_get_local_pid">enif_get_local_pid() </a></li> <li title="enif_get_list_cell"><a href="erl_nif.html#enif_get_list_cell">enif_get_list_cell() </a></li> <li title="enif_get_list_length"><a href="erl_nif.html#enif_get_list_length">enif_get_list_length() </a></li> <li title="enif_get_long"><a href="erl_nif.html#enif_get_long">enif_get_long() </a></li> <li title="enif_get_resource"><a href="erl_nif.html#enif_get_resource">enif_get_resource() </a></li> <li title="enif_get_string"><a href="erl_nif.html#enif_get_string">enif_get_string() </a></li> <li title="enif_get_tuple"><a href="erl_nif.html#enif_get_tuple">enif_get_tuple() </a></li> <li title="enif_get_uint"><a href="erl_nif.html#enif_get_uint">enif_get_uint() </a></li> <li title="enif_get_uint64"><a href="erl_nif.html#enif_get_uint64">enif_get_uint64() </a></li> <li title="enif_get_ulong"><a href="erl_nif.html#enif_get_ulong">enif_get_ulong() </a></li> <li title="enif_inspect_binary"><a href="erl_nif.html#enif_inspect_binary">enif_inspect_binary() </a></li> <li title="enif_inspect_iolist_as_binary"><a href="erl_nif.html#enif_inspect_iolist_as_binary">enif_inspect_iolist_as_binary() </a></li> <li title="enif_is_atom"><a href="erl_nif.html#enif_is_atom">enif_is_atom() </a></li> <li title="enif_is_binary"><a href="erl_nif.html#enif_is_binary">enif_is_binary() </a></li> <li title="enif_is_empty_list"><a href="erl_nif.html#enif_is_empty_list">enif_is_empty_list() </a></li> <li title="enif_is_exception"><a href="erl_nif.html#enif_is_exception">enif_is_exception() </a></li> <li title="enif_is_number"><a href="erl_nif.html#enif_is_number">enif_is_number() </a></li> <li title="enif_is_fun"><a href="erl_nif.html#enif_is_fun">enif_is_fun() </a></li> <li title="enif_is_identical"><a href="erl_nif.html#enif_is_identical">enif_is_identical() </a></li> <li title="enif_is_pid"><a href="erl_nif.html#enif_is_pid">enif_is_pid() </a></li> <li title="enif_is_port"><a href="erl_nif.html#enif_is_port">enif_is_port() </a></li> <li title="enif_is_ref"><a href="erl_nif.html#enif_is_ref">enif_is_ref() </a></li> <li title="enif_is_tuple"><a href="erl_nif.html#enif_is_tuple">enif_is_tuple() </a></li> <li title="enif_is_list"><a href="erl_nif.html#enif_is_list">enif_is_list() </a></li> <li title="enif_keep_resource"><a href="erl_nif.html#enif_keep_resource">enif_keep_resource() </a></li> <li title="enif_make_atom"><a href="erl_nif.html#enif_make_atom">enif_make_atom() </a></li> <li title="enif_make_atom_len"><a href="erl_nif.html#enif_make_atom_len">enif_make_atom_len() </a></li> <li title="enif_make_badarg"><a href="erl_nif.html#enif_make_badarg">enif_make_badarg() </a></li> <li title="enif_make_binary"><a href="erl_nif.html#enif_make_binary">enif_make_binary() </a></li> <li title="enif_make_copy"><a href="erl_nif.html#enif_make_copy">enif_make_copy() </a></li> <li title="enif_make_double"><a href="erl_nif.html#enif_make_double">enif_make_double() </a></li> <li title="enif_make_existing_atom"><a href="erl_nif.html#enif_make_existing_atom">enif_make_existing_atom() </a></li> <li title="enif_make_existing_atom_len"><a href="erl_nif.html#enif_make_existing_atom_len">enif_make_existing_atom_len() </a></li> <li title="enif_make_int"><a href="erl_nif.html#enif_make_int">enif_make_int() </a></li> <li title="enif_make_int64"><a href="erl_nif.html#enif_make_int64">enif_make_int64() </a></li> <li title="enif_make_list"><a href="erl_nif.html#enif_make_list">enif_make_list() </a></li> <li title="enif_make_list1"><a href="erl_nif.html#enif_make_list1">enif_make_list1() </a></li> <li title="enif_make_list2"><a href="erl_nif.html#enif_make_list2">enif_make_list2() </a></li> <li title="enif_make_list3"><a href="erl_nif.html#enif_make_list3">enif_make_list3() </a></li> <li title="enif_make_list4"><a href="erl_nif.html#enif_make_list4">enif_make_list4() </a></li> <li title="enif_make_list5"><a href="erl_nif.html#enif_make_list5">enif_make_list5() </a></li> <li title="enif_make_list6"><a href="erl_nif.html#enif_make_list6">enif_make_list6() </a></li> <li title="enif_make_list7"><a href="erl_nif.html#enif_make_list7">enif_make_list7() </a></li> <li title="enif_make_list8"><a href="erl_nif.html#enif_make_list8">enif_make_list8() </a></li> <li title="enif_make_list9"><a href="erl_nif.html#enif_make_list9">enif_make_list9() </a></li> <li title="enif_make_list_cell"><a href="erl_nif.html#enif_make_list_cell">enif_make_list_cell() </a></li> <li title="enif_make_list_from_array"><a href="erl_nif.html#enif_make_list_from_array">enif_make_list_from_array() </a></li> <li title="enif_make_reverse_list"><a href="erl_nif.html#enif_make_reverse_list">enif_make_reverse_list() </a></li> <li title="enif_make_long"><a href="erl_nif.html#enif_make_long">enif_make_long() </a></li> <li title="enif_make_new_binary"><a href="erl_nif.html#enif_make_new_binary">enif_make_new_binary() </a></li> <li title="enif_make_pid"><a href="erl_nif.html#enif_make_pid">enif_make_pid() </a></li> <li title="enif_make_ref"><a href="erl_nif.html#enif_make_ref">enif_make_ref() </a></li> <li title="enif_make_resource"><a href="erl_nif.html#enif_make_resource">enif_make_resource() </a></li> <li title="enif_make_resource_binary"><a href="erl_nif.html#enif_make_resource_binary">enif_make_resource_binary() </a></li> <li title="enif_make_string"><a href="erl_nif.html#enif_make_string">enif_make_string() </a></li> <li title="enif_make_string_len"><a href="erl_nif.html#enif_make_string_len">enif_make_string_len() </a></li> <li title="enif_make_sub_binary"><a href="erl_nif.html#enif_make_sub_binary">enif_make_sub_binary() </a></li> <li title="enif_make_tuple"><a href="erl_nif.html#enif_make_tuple">enif_make_tuple() </a></li> <li title="enif_make_tuple1"><a href="erl_nif.html#enif_make_tuple1">enif_make_tuple1() </a></li> <li title="enif_make_tuple2"><a href="erl_nif.html#enif_make_tuple2">enif_make_tuple2() </a></li> <li title="enif_make_tuple3"><a href="erl_nif.html#enif_make_tuple3">enif_make_tuple3() </a></li> <li title="enif_make_tuple4"><a href="erl_nif.html#enif_make_tuple4">enif_make_tuple4() </a></li> <li title="enif_make_tuple5"><a href="erl_nif.html#enif_make_tuple5">enif_make_tuple5() </a></li> <li title="enif_make_tuple6"><a href="erl_nif.html#enif_make_tuple6">enif_make_tuple6() </a></li> <li title="enif_make_tuple7"><a href="erl_nif.html#enif_make_tuple7">enif_make_tuple7() </a></li> <li title="enif_make_tuple8"><a href="erl_nif.html#enif_make_tuple8">enif_make_tuple8() </a></li> <li title="enif_make_tuple9"><a href="erl_nif.html#enif_make_tuple9">enif_make_tuple9() </a></li> <li title="enif_make_tuple_from_array"><a href="erl_nif.html#enif_make_tuple_from_array">enif_make_tuple_from_array() </a></li> <li title="enif_make_uint"><a href="erl_nif.html#enif_make_uint">enif_make_uint() </a></li> <li title="enif_make_uint64"><a href="erl_nif.html#enif_make_uint64">enif_make_uint64() </a></li> <li title="enif_make_ulong"><a href="erl_nif.html#enif_make_ulong">enif_make_ulong() </a></li> <li title="enif_mutex_create"><a href="erl_nif.html#enif_mutex_create">enif_mutex_create() </a></li> <li title="enif_mutex_destroy"><a href="erl_nif.html#enif_mutex_destroy">enif_mutex_destroy() </a></li> <li title="enif_mutex_lock"><a href="erl_nif.html#enif_mutex_lock">enif_mutex_lock() </a></li> <li title="enif_mutex_trylock"><a href="erl_nif.html#enif_mutex_trylock">enif_mutex_trylock() </a></li> <li title="enif_mutex_unlock"><a href="erl_nif.html#enif_mutex_unlock">enif_mutex_unlock() </a></li> <li title="enif_open_resource_type"><a href="erl_nif.html#enif_open_resource_type">enif_open_resource_type() </a></li> <li title="enif_priv_data"><a href="erl_nif.html#enif_priv_data">enif_priv_data() </a></li> <li title="enif_realloc_binary"><a href="erl_nif.html#enif_realloc_binary">enif_realloc_binary() </a></li> <li title="enif_release_binary"><a href="erl_nif.html#enif_release_binary">enif_release_binary() </a></li> <li title="enif_release_resource"><a href="erl_nif.html#enif_release_resource">enif_release_resource() </a></li> <li title="enif_rwlock_create"><a href="erl_nif.html#enif_rwlock_create">enif_rwlock_create() </a></li> <li title="enif_rwlock_destroy"><a href="erl_nif.html#enif_rwlock_destroy">enif_rwlock_destroy() </a></li> <li title="enif_rwlock_rlock"><a href="erl_nif.html#enif_rwlock_rlock">enif_rwlock_rlock() </a></li> <li title="enif_rwlock_runlock"><a href="erl_nif.html#enif_rwlock_runlock">enif_rwlock_runlock() </a></li> <li title="enif_rwlock_rwlock"><a href="erl_nif.html#enif_rwlock_rwlock">enif_rwlock_rwlock() </a></li> <li title="enif_rwlock_rwunlock"><a href="erl_nif.html#enif_rwlock_rwunlock">enif_rwlock_rwunlock() </a></li> <li title="enif_rwlock_tryrlock"><a href="erl_nif.html#enif_rwlock_tryrlock">enif_rwlock_tryrlock() </a></li> <li title="enif_rwlock_tryrwlock"><a href="erl_nif.html#enif_rwlock_tryrwlock">enif_rwlock_tryrwlock() </a></li> <li title="enif_self"><a href="erl_nif.html#enif_self">enif_self() </a></li> <li title="enif_send"><a href="erl_nif.html#enif_send">enif_send() </a></li> <li title="enif_sizeof_resource"><a href="erl_nif.html#enif_sizeof_resource">enif_sizeof_resource() </a></li> <li title="enif_system_info"><a href="erl_nif.html#enif_system_info">enif_system_info() </a></li> <li title="enif_thread_create"><a href="erl_nif.html#enif_thread_create">enif_thread_create() </a></li> <li title="enif_thread_exit"><a href="erl_nif.html#enif_thread_exit">enif_thread_exit() </a></li> <li title="enif_thread_join"><a href="erl_nif.html#enif_thread_join">enif_thread_join() </a></li> <li title="enif_thread_opts_create"><a href="erl_nif.html#enif_thread_opts_create">enif_thread_opts_create() </a></li> <li title="enif_thread_opts_destroy"><a href="erl_nif.html#enif_thread_opts_destroy">enif_thread_opts_destroy() </a></li> <li title="enif_thread_self"><a href="erl_nif.html#enif_thread_self">enif_thread_self() </a></li> <li title="enif_tsd_key_create"><a href="erl_nif.html#enif_tsd_key_create">enif_tsd_key_create() </a></li> <li title="enif_tsd_key_destroy"><a href="erl_nif.html#enif_tsd_key_destroy">enif_tsd_key_destroy() </a></li> <li title="enif_tsd_get"><a href="erl_nif.html#enif_tsd_get">enif_tsd_get() </a></li> <li title="enif_tsd_set"><a href="erl_nif.html#enif_tsd_set">enif_tsd_set() </a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>erlang</h1></center> <h3>MODULE</h3> <div class="REFBODY">erlang</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">The Erlang BIFs</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>By convention, most built-in functions (BIFs) are seen as being in the module <span class="code">erlang</span>. A number of the BIFs are viewed more or less as part of the Erlang programming language and are <strong>auto-imported</strong>. Thus, it is not necessary to specify the module name and both the calls <span class="code">atom_to_list(Erlang)</span> and <span class="code">erlang:atom_to_list(Erlang)</span> are identical.</p> <p>In the text, auto-imported BIFs are listed without module prefix. BIFs listed with module prefix are not auto-imported.</p> <p>BIFs may fail for a variety of reasons. All BIFs fail with reason <span class="code">badarg</span> if they are called with arguments of an incorrect type. The other reasons that may make BIFs fail are described in connection with the description of each individual BIF.</p> <p>Some BIFs may be used in guard tests, these are marked with "Allowed in guard tests".</p> </p></div> <h3>DATA TYPES</h3> <p><span class="bold_code"><a name="type-ext_binary">ext_binary()</a></span></p> <div class="REFBODY"><p> <p>A binary data object, structured according to the Erlang external term format.</p> </p></div> <p> <span class="bold_code"><a name="type-timestamp">timestamp()</a> = <br> {MegaSecs :: integer() >= 0,<br> Secs :: integer() >= 0,<br> MicroSecs :: integer() >= 0}</span><br></p> <div class="REFBODY"><p><p>See <span class="bold_code"><a href="#now-0">now/0</a></span>.</p> </p></div> <h3>EXPORTS</h3> <p><a name="abs-1"><span class="bold_code">abs(Number) -> integer() | float()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Number = number()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer or float which is the arithmetical absolute value of <span class="code">Number</span>.</p> <div class="example"><pre> > <span class="bold_code">abs(-3.33).</span> 3.33 > <span class="bold_code">abs(-3).</span> 3</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="adler32-1"><span class="bold_code">erlang:adler32(Data) -> integer()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> </div> <div class="REFBODY"><p> <p>Computes and returns the adler32 checksum for <span class="code">Data</span>.</p> </p></div> <p><a name="adler32-2"><span class="bold_code">erlang:adler32(OldAdler, Data) -> integer()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">OldAdler = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> </div> <div class="REFBODY"><p> <p>Continue computing the adler32 checksum by combining the previous checksum, <span class="code">OldAdler</span>, with the checksum of <span class="code">Data</span>.</p> <p>The following code:</p> <div class="example"><pre> X = erlang:adler32(Data1), Y = erlang:adler32(X,Data2). </pre></div> <p>- would assign the same value to <span class="code">Y</span> as this would:</p> <div class="example"><pre> Y = erlang:adler32([Data1,Data2]). </pre></div> </p></div> <p><a name="adler32_combine-3"><span class="bold_code">erlang:adler32_combine(FirstAdler, SecondAdler, SecondSize) -> integer()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">FirstAdler = SecondAdler = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">SecondSize = integer()</span><br> </div> </div> <div class="REFBODY"><p> <p>Combines two previously computed adler32 checksums. This computation requires the size of the data object for the second checksum to be known.</p> <p>The following code:</p> <div class="example"><pre> Y = erlang:adler32(Data1), Z = erlang:adler32(Y,Data2). </pre></div> <p>- would assign the same value to <span class="code">Z</span> as this would:</p> <div class="example"><pre> X = erlang:adler32(Data1), Y = erlang:adler32(Data2), Z = erlang:adler32_combine(X,Y,iolist_size(Data2)). </pre></div> </p></div> <p><a name="append_element-2"><span class="bold_code">erlang:append_element(Tuple1, Term) -> Tuple2</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Tuple1 = Tuple2 = tuple()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a new tuple which has one element more than <span class="code">Tuple1</span>, and contains the elements in <span class="code">Tuple1</span> followed by <span class="code">Term</span> as the last element. Semantically equivalent to <span class="code">list_to_tuple(tuple_to_list(Tuple) ++ [Term])</span>, but much faster.</p> <div class="example"><pre> > <span class="bold_code">erlang:append_element({one, two}, three).</span> {one,two,three}</pre></div> </p></div> <p><a name="apply-2"></a><span class="bold_code">apply(Fun, Args) -> term()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> </div></p> <div class="REFBODY"><p> <p>Call a fun, passing the elements in <span class="code">Args</span> as arguments.</p> <p>Note: If the number of elements in the arguments are known at compile-time, the call is better written as <span class="code">Fun(Arg1, Arg2, ... ArgN)</span>.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>Earlier, <span class="code">Fun</span> could also be given as <span class="code">{Module, Function}</span>, equivalent to <span class="code">apply(Module, Function, Args)</span>. This usage is deprecated and will stop working in a future release of Erlang/OTP.</p> </p></div> </div> </p></div> <p><a name="apply-3"></a><span class="bold_code">apply(Module, Function, Args) -> term()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Module = module()</span></div> <div class="REFTYPES"><span class="bold_code">Function = atom()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the result of applying <span class="code">Function</span> in <span class="code">Module</span> to <span class="code">Args</span>. The applied function must be exported from <span class="code">Module</span>. The arity of the function is the length of <span class="code">Args</span>.</p> <div class="example"><pre> > <span class="bold_code">apply(lists, reverse, [[a, b, c]]).</span> [c,b,a]</pre></div> <p><span class="code">apply</span> can be used to evaluate BIFs by using the module name <span class="code">erlang</span>.</p> <div class="example"><pre> > <span class="bold_code">apply(erlang, atom_to_list, ['Erlang']).</span> "Erlang"</pre></div> <p>Note: If the number of arguments are known at compile-time, the call is better written as <span class="code">Module:Function(Arg1, Arg2, ..., ArgN)</span>.</p> <p>Failure: <span class="code">error_handler:undefined_function/3</span> is called if the applied function is not exported. The error handler can be redefined (see <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>). If the <span class="code">error_handler</span> is undefined, or if the user has redefined the default <span class="code">error_handler</span> so the replacement module is undefined, an error with the reason <span class="code">undef</span> is generated.</p> </p></div> <p><a name="atom_to_binary-2"><span class="bold_code">atom_to_binary(Atom, Encoding) -> binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Atom = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Encoding = latin1 | utf8 | unicode</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a binary which corresponds to the text representation of <span class="code">Atom</span>. If <span class="code">Encoding</span> is <span class="code">latin1</span>, there will be one byte for each character in the text representation. If <span class="code">Encoding</span> is <span class="code">utf8</span> or <span class="code">unicode</span>, the characters will be encoded using UTF-8 (meaning that characters from 16#80 up to 0xFF will be encoded in two bytes).</p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p>Currently, <span class="code">atom_to_binary(Atom, latin1)</span> can never fail because the text representation of an atom can only contain characters from 0 to 16#FF. In a future release, the text representation of atoms might be allowed to contain any Unicode character and <span class="code">atom_to_binary(Atom, latin1)</span> will fail if the text representation for the <span class="code">Atom</span> contains a Unicode character greater than 16#FF.</p></p></div> </div> <div class="example"><pre> > <span class="bold_code">atom_to_binary('Erlang', latin1).</span> <<"Erlang">></pre></div> </p></div> <p><a name="atom_to_list-1"><span class="bold_code">atom_to_list(Atom) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Atom = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Atom</span>.</p> <div class="example"><pre> > <span class="bold_code">atom_to_list('Erlang').</span> "Erlang"</pre></div> </p></div> <p><a name="binary_part-2"><span class="bold_code">binary_part(Subject, PosLen) -> binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Subject = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PosLen = {Start,Length}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Start = integer() >= 0</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Length = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>Extracts the part of the binary described by <span class="code">PosLen</span>.</p> <p>Negative length can be used to extract bytes at the end of a binary:</p> <div class="example"><pre> 1> Bin = <<1,2,3,4,5,6,7,8,9,10>>. 2> binary_part(Bin,{byte_size(Bin), -5)). <<6,7,8,9,10>> </pre></div> <p>If <span class="code">PosLen</span> in any way references outside the binary, a <span class="code">badarg</span> exception is raised.</p> <p><span class="code">Start</span> is zero-based, i.e.:</p> <div class="example"><pre> 1> Bin = <<1,2,3>> 2> binary_part(Bin,{0,2}). <<1,2>> </pre></div> <p>See the STDLIB module <span class="code">binary</span> for details about the <span class="code">PosLen</span> semantics.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="binary_part-3"><span class="bold_code">binary_part(Subject, Start, Length) -> binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Subject = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Start = integer() >= 0</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Length = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>The same as <span class="code">binary_part(Subject, {Pos, Len})</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="binary_to_atom-2"><span class="bold_code">binary_to_atom(Binary, Encoding) -> atom()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Binary = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Encoding = latin1 | utf8 | unicode</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the atom whose text representation is <span class="code">Binary</span>. If <span class="code">Encoding</span> is <span class="code">latin1</span>, no translation of bytes in the binary is done. If <span class="code">Encoding</span> is <span class="code">utf8</span> or <span class="code">unicode</span>, the binary must contain valid UTF-8 sequences; furthermore, only Unicode characters up to 0xFF are allowed.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p><span class="code">binary_to_atom(Binary, utf8)</span> will fail if the binary contains Unicode characters greater than 16#FF. In a future release, such Unicode characters might be allowed and <span class="code">binary_to_atom(Binary, utf8)</span> will not fail in that case.</p></p></div> </div> <div class="example"><pre> > <span class="bold_code">binary_to_atom(<<"Erlang">>, latin1).</span> 'Erlang' > <span class="bold_code">binary_to_atom(<<1024/utf8>>, utf8).</span> ** exception error: bad argument in function binary_to_atom/2 called as binary_to_atom(<<208,128>>,utf8)</pre></div> </p></div> <p><a name="binary_to_existing_atom-2"><span class="bold_code">binary_to_existing_atom(Binary, Encoding) -> atom()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Binary = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Encoding = latin1 | utf8 | unicode</span><br> </div> </div> <div class="REFBODY"><p> <p>Works like <span class="bold_code"><a href="#binary_to_atom-2">binary_to_atom/2</a></span>, but the atom must already exist.</p> <p>Failure: <span class="code">badarg</span> if the atom does not already exist.</p> </p></div> <p><a name="binary_to_list-1"><span class="bold_code">binary_to_list(Binary) -> [char()]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Binary = binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of integers which correspond to the bytes of <span class="code">Binary</span>.</p> </p></div> <p><a name="binary_to_list-3"><span class="bold_code">binary_to_list(Binary, Start, Stop) -> [char()]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Binary = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Start = Stop = 1..byte_size(Binary)</span><br> </div> </div> <div class="REFBODY"><p> <p>As <span class="code">binary_to_list/1</span>, but returns a list of integers corresponding to the bytes from position <span class="code">Start</span> to position <span class="code">Stop</span> in <span class="code">Binary</span>. Positions in the binary are numbered starting from 1.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p>This function's indexing style of using one-based indices for binaries is deprecated. New code should use the functions in the STDLIB module <span class="code">binary</span> instead. They consequently use the same (zero-based) style of indexing.</p></p></div> </div> </p></div> <p><a name="bitstring_to_list-1"><span class="bold_code">bitstring_to_list(Bitstring) -> [char()|bitstring()]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Bitstring = bitstring()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of integers which correspond to the bytes of <span class="code">Bitstring</span>. If the number of bits in the binary is not divisible by 8, the last element of the list will be a bitstring containing the remaining bits (1 up to 7 bits).</p> </p></div> <p><a name="binary_to_term-1"><span class="bold_code">binary_to_term(Binary) -> term()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Binary = <span class="bold_code"><a href="#type-ext_binary">ext_binary()</a></span></span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an Erlang term which is the result of decoding the binary object <span class="code">Binary</span>, which must be encoded according to the Erlang external term format.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>When decoding binaries from untrusted sources, consider using <span class="code">binary_to_term/2</span> to prevent denial of service attacks.</p> </p></div> </div> <p>See also <span class="bold_code"><a href="#term_to_binary-1">term_to_binary/1</a></span> and <span class="bold_code"><a href="#binary_to_term-2">binary_to_term/2</a></span>.</p> </p></div> <p><a name="binary_to_term-2"><span class="bold_code">binary_to_term(Binary, Opts) -> term()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Opts = [safe]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Binary = <span class="bold_code"><a href="#type-ext_binary">ext_binary()</a></span></span><br> </div> </div> <div class="REFBODY"><p> <p>As <span class="code">binary_to_term/1</span>, but takes options that affect decoding of the binary.</p> <dl> <dt><strong><span class="code">safe</span></strong></dt> <dd> <p>Use this option when receiving binaries from an untrusted source.</p> <p>When enabled, it prevents decoding data that may be used to attack the Erlang system. In the event of receiving unsafe data, decoding fails with a badarg error.</p> <p>Currently, this prevents creation of new atoms directly, creation of new atoms indirectly (as they are embedded in certain structures like pids, refs, funs, etc.), and creation of new external function references. None of those resources are currently garbage collected, so unchecked creation of them can exhaust available memory.</p> </dd> </dl> <p>Failure: <span class="code">badarg</span> if <span class="code">safe</span> is specified and unsafe data is decoded.</p> <p>See also <span class="bold_code"><a href="#term_to_binary-1">term_to_binary/1</a></span>, <span class="bold_code"><a href="#binary_to_term-1">binary_to_term/1</a></span>, and <span class="bold_code"><a href="#list_to_existing_atom-1"> list_to_existing_atom/1</a></span>.</p> </p></div> <p><a name="bit_size-1"><span class="bold_code">bit_size(Bitstring) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Bitstring = bitstring()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer which is the size in bits of <span class="code">Bitstring</span>.</p> <div class="example"><pre> > <span class="bold_code">bit_size(<<433:16,3:3>>).</span> 19 > <span class="bold_code">bit_size(<<1,2,3>>).</span> 24</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="bump_reductions-1"><span class="bold_code">erlang:bump_reductions(Reductions) -> void()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Reductions = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>This implementation-dependent function increments the reduction counter for the calling process. In the Beam emulator, the reduction counter is normally incremented by one for each function and BIF call, and a context switch is forced when the counter reaches the maximum number of reductions for a process (2000 reductions in R12B).</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF might be removed in a future version of the Beam machine without prior warning. It is unlikely to be implemented in other Erlang implementations.</p> </p></div> </div> </p></div> <p><a name="byte_size-1"><span class="bold_code">byte_size(Bitstring) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Bitstring = bitstring()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer which is the number of bytes needed to contain <span class="code">Bitstring</span>. (That is, if the number of bits in <span class="code">Bitstring</span> is not divisible by 8, the resulting number of bytes will be rounded <strong>up</strong>.)</p> <div class="example"><pre> > <span class="bold_code">byte_size(<<433:16,3:3>>).</span> 3 > <span class="bold_code">byte_size(<<1,2,3>>).</span> 3</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="cancel_timer-1"><span class="bold_code">erlang:cancel_timer(TimerRef) -> Time | false</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">TimerRef = reference()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Time = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>Cancels a timer, where <span class="code">TimerRef</span> was returned by either <span class="bold_code"><a href="#send_after-3">erlang:send_after/3</a></span> or <span class="bold_code"><a href="#start_timer-3">erlang:start_timer/3</a></span>. If the timer is there to be removed, the function returns the time in milliseconds left until the timer would have expired, otherwise <span class="code">false</span> (which means that <span class="code">TimerRef</span> was never a timer, that it has already been cancelled, or that it has already delivered its message).</p> <p>See also <span class="bold_code"><a href="#send_after-3">erlang:send_after/3</a></span>, <span class="bold_code"><a href="#start_timer-3">erlang:start_timer/3</a></span>, and <span class="bold_code"><a href="#read_timer-1">erlang:read_timer/1</a></span>.</p> <p>Note: Cancelling a timer does not guarantee that the message has not already been delivered to the message queue.</p> </p></div> <p><a name="check_old_code-1"><span class="bold_code">check_old_code(Module) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if the <span class="code">Module</span> has old code, and <span class="code">false</span> otherwise.</p> <p>See also <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>.</p> </p></div> <p><a name="check_process_code-2"><span class="bold_code">check_process_code(Pid, Module) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if the process <span class="code">Pid</span> is executing old code for <span class="code">Module</span>. That is, if the current call of the process executes old code for this module, or if the process has references to old code for this module, or if the process contains funs that references old code for this module. Otherwise, it returns <span class="code">false</span>.</p> <div class="example"><pre> > <span class="bold_code">check_process_code(Pid, lists).</span> false</pre></div> <p>See also <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>.</p> </p></div> <p><a name="crc32-1"><span class="bold_code">erlang:crc32(Data) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> </div> <div class="REFBODY"><p> <p>Computes and returns the crc32 (IEEE 802.3 style) checksum for <span class="code">Data</span>.</p> </p></div> <p><a name="crc32-2"><span class="bold_code">erlang:crc32(OldCrc, Data) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">OldCrc = integer() >= 0</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> </div> <div class="REFBODY"><p> <p>Continue computing the crc32 checksum by combining the previous checksum, <span class="code">OldCrc</span>, with the checksum of <span class="code">Data</span>.</p> <p>The following code:</p> <div class="example"><pre> X = erlang:crc32(Data1), Y = erlang:crc32(X,Data2). </pre></div> <p>- would assign the same value to <span class="code">Y</span> as this would:</p> <div class="example"><pre> Y = erlang:crc32([Data1,Data2]). </pre></div> </p></div> <p><a name="crc32_combine-3"><span class="bold_code">erlang:crc32_combine(FirstCrc, SecondCrc, SecondSize) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">FirstCrc = SecondCrc = integer() >= 0</span><br> </div> <div class="REFTYPES"> <span class="bold_code">SecondSize = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>Combines two previously computed crc32 checksums. This computation requires the size of the data object for the second checksum to be known.</p> <p>The following code:</p> <div class="example"><pre> Y = erlang:crc32(Data1), Z = erlang:crc32(Y,Data2). </pre></div> <p>- would assign the same value to <span class="code">Z</span> as this would:</p> <div class="example"><pre> X = erlang:crc32(Data1), Y = erlang:crc32(Data2), Z = erlang:crc32_combine(X,Y,iolist_size(Data2)). </pre></div> </p></div> <p><a name="date-0"><span class="bold_code">date() -> Date</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Date = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-date');">calendar:date()</a></span></span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the current date as <span class="code">{Year, Month, Day}</span>.</p> <p>The time zone and daylight saving time correction depend on the underlying OS.</p> <div class="example"><pre> > <span class="bold_code">date().</span> {1995,2,19}</pre></div> </p></div> <p><a name="decode_packet-3"><span class="bold_code">erlang:decode_packet(Type,Bin,Options) -> {ok,Packet,Rest} | {more,Length} | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Bin = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Opt]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Packet = binary() | HttpPacket</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Rest = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Length = integer() > 0 | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Type, Opt -- see below</span><br> </div> <div class="REFTYPES"> <span class="bold_code"></span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpPacket = HttpRequest | HttpResponse | HttpHeader | http_eoh | HttpError</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpRequest = {http_request, HttpMethod, HttpUri, HttpVersion}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpResponse = {http_response, HttpVersion, integer(), HttpString}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpHeader = {http_header, integer(), HttpField, Reserved=term(), Value=HttpString}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpError = {http_error, HttpString}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpMethod = HttpMethodAtom | HttpString</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpMethodAtom = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE'</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpUri = '*' | {absoluteURI, http|https, Host=HttpString, Port=integer()|undefined, Path=HttpString} | {scheme, Scheme=HttpString, HttpString} | {abs_path, HttpString} | HttpString</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpVersion = {Major=integer(), Minor=integer()}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpString = string() | binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpField = HttpFieldAtom | HttpString</span><br> </div> <div class="REFTYPES"> <span class="bold_code">HttpFieldAtom = 'Cache-Control' | 'Connection' | 'Date' | 'Pragma' | 'Transfer-Encoding' | 'Upgrade' | 'Via' | 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Authorization' | 'From' | 'Host' | 'If-Modified-Since' | 'If-Match' | 'If-None-Match' | 'If-Range' | 'If-Unmodified-Since' | 'Max-Forwards' | 'Proxy-Authorization' | 'Range' | 'Referer' | 'User-Agent' | 'Age' | 'Location' | 'Proxy-Authenticate' | 'Public' | 'Retry-After' | 'Server' | 'Vary' | 'Warning' | 'Www-Authenticate' | 'Allow' | 'Content-Base' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Md5' | 'Content-Range' | 'Content-Type' | 'Etag' | 'Expires' | 'Last-Modified' | 'Accept-Ranges' | 'Set-Cookie' | 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive' | 'Proxy-Connection'</span><br> </div> <div class="REFTYPES"> <span class="bold_code"></span><br> </div> </div> <div class="REFBODY"><p> <p>Decodes the binary <span class="code">Bin</span> according to the packet protocol specified by <span class="code">Type</span>. Very similar to the packet handling done by sockets with the option {packet,Type}.</p> <p>If an entire packet is contained in <span class="code">Bin</span> it is returned together with the remainder of the binary as <span class="code">{ok,Packet,Rest}</span>.</p> <p>If <span class="code">Bin</span> does not contain the entire packet, <span class="code">{more,Length}</span> is returned. <span class="code">Length</span> is either the expected <strong>total size</strong> of the packet or <span class="code">undefined</span> if the expected packet size is not known. <span class="code">decode_packet</span> can then be called again with more data added.</p> <p>If the packet does not conform to the protocol format <span class="code">{error,Reason}</span> is returned.</p> <p>The following values of <span class="code">Type</span> are valid:</p> <dl> <dt><strong><span class="code">raw | 0</span></strong></dt> <dd> <p>No packet handling is done. Entire binary is returned unless it is empty.</p> </dd> <dt><strong><span class="code">1 | 2 | 4</span></strong></dt> <dd> <p>Packets consist of a header specifying the number of bytes in the packet, followed by that number of bytes. The length of header can be one, two, or four bytes; the order of the bytes is big-endian. The header will be stripped off when the packet is returned.</p> </dd> <dt><strong><span class="code">line</span></strong></dt> <dd> <p>A packet is a line terminated with newline. The newline character is included in the returned packet unless the line was truncated according to the option <span class="code">line_length</span>.</p> </dd> <dt><strong><span class="code">asn1 | cdr | sunrm | fcgi | tpkt</span></strong></dt> <dd> <p>The header is <strong>not</strong> stripped off.</p> <p>The meanings of the packet types are as follows:</p> <dl> <dt><strong><span class="code">asn1</span> - ASN.1 BER</strong></dt> <dd></dd> <dt><strong><span class="code">sunrm</span> - Sun's RPC encoding</strong></dt> <dd></dd> <dt><strong><span class="code">cdr</span> - CORBA (GIOP 1.1)</strong></dt> <dd></dd> <dt><strong><span class="code">fcgi</span> - Fast CGI</strong></dt> <dd></dd> <dt><strong><span class="code">tpkt</span> - TPKT format [RFC1006]</strong></dt> <dd></dd> </dl> </dd> <dt><strong><span class="code">http | httph | http_bin | httph_bin</span></strong></dt> <dd> <p>The Hypertext Transfer Protocol. The packets are returned with the format according to <span class="code">HttpPacket</span> described above. A packet is either a request, a response, a header or an end of header mark. Invalid lines are returned as <span class="code">HttpError</span>.</p> <p>Recognized request methods and header fields are returned as atoms. Others are returned as strings.</p> <p>The protocol type <span class="code">http</span> should only be used for the first line when a <span class="code">HttpRequest</span> or a <span class="code">HttpResponse</span> is expected. The following calls should use <span class="code">httph</span> to get <span class="code">HttpHeader</span>'s until <span class="code">http_eoh</span> is returned that marks the end of the headers and the beginning of any following message body.</p> <p>The variants <span class="code">http_bin</span> and <span class="code">httph_bin</span> will return strings (<span class="code">HttpString</span>) as binaries instead of lists.</p> </dd> </dl> <p>The following options are available:</p> <dl> <dt><strong><span class="code">{packet_size, integer()}</span></strong></dt> <dd> <p>Sets the max allowed size of the packet body. If the packet header indicates that the length of the packet is longer than the max allowed length, the packet is considered invalid. Default is 0 which means no size limit.</p> </dd> <dt><strong><span class="code">{line_length, integer()}</span></strong></dt> <dd> <p>For packet type <span class="code">line</span>, truncate lines longer than the indicated length.</p> <p>Option <span class="code">line_length</span> also applies to <span class="code">http*</span> packet types as an alias for option <span class="code">packet_size</span> in the case when <span class="code">packet_size</span> itself is not set. This usage is only intended for backward compatibility.</p> </dd> </dl> <div class="example"><pre> > <span class="bold_code">erlang:decode_packet(1,<<3,"abcd">>,[]).</span> {ok,<<"abc">>,<<"d">>} > <span class="bold_code">erlang:decode_packet(1,<<5,"abcd">>,[]).</span> {more,6}</pre></div> </p></div> <p><a name="delete_module-1"><span class="bold_code">delete_module(Module) -> true | undefined</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Makes the current code for <span class="code">Module</span> become old code, and deletes all references for this module from the export table. Returns <span class="code">undefined</span> if the module does not exist, otherwise <span class="code">true</span>.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for the code server (see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>) and should not be used elsewhere.</p> </p></div> </div> <p>Failure: <span class="code">badarg</span> if there is already an old version of <span class="code">Module</span>.</p> </p></div> <p><a name="demonitor-1"><span class="bold_code">demonitor(MonitorRef) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MonitorRef = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p>If <span class="code">MonitorRef</span> is a reference which the calling process obtained by calling <span class="bold_code"><a href="#monitor-2">monitor/2</a></span>, this monitoring is turned off. If the monitoring is already turned off, nothing happens.</p> <p>Once <span class="code">demonitor(MonitorRef)</span> has returned it is guaranteed that no <span class="code">{'DOWN', MonitorRef, _, _, _}</span> message due to the monitor will be placed in the caller's message queue in the future. A <span class="code">{'DOWN', MonitorRef, _, _, _}</span> message might have been placed in the caller's message queue prior to the call, though. Therefore, in most cases, it is advisable to remove such a <span class="code">'DOWN'</span> message from the message queue after monitoring has been stopped. <span class="bold_code"><a href="#demonitor-2">demonitor(MonitorRef, [flush])</a></span> can be used instead of <span class="code">demonitor(MonitorRef)</span> if this cleanup is wanted.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>Prior to OTP release R11B (erts version 5.5) <span class="code">demonitor/1</span> behaved completely asynchronous, i.e., the monitor was active until the "demonitor signal" reached the monitored entity. This had one undesirable effect, though. You could never know when you were guaranteed <strong>not</strong> to receive a <span class="code">DOWN</span> message due to the monitor.</p> <p>Current behavior can be viewed as two combined operations: asynchronously send a "demonitor signal" to the monitored entity and ignore any future results of the monitor. </p> </p></div> </div> <p>Failure: It is an error if <span class="code">MonitorRef</span> refers to a monitoring started by another process. Not all such cases are cheap to check; if checking is cheap, the call fails with <span class="code">badarg</span> (for example if <span class="code">MonitorRef</span> is a remote reference).</p> </p></div> <p><a name="demonitor-2"><span class="bold_code">demonitor(MonitorRef, OptionList) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MonitorRef = reference()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">OptionList = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Option = flush | info</span><br> </div> </div> <div class="REFBODY"><p> <p>The returned value is <span class="code">true</span> unless <span class="code">info</span> is part of <span class="code">OptionList</span>. </p> <p><span class="code">demonitor(MonitorRef, [])</span> is equivalent to <span class="bold_code"><a href="#demonitor-1">demonitor(MonitorRef)</a></span>.</p> <p>Currently the following <span class="code">Option</span>s are valid:</p> <dl> <dt><strong><span class="code">flush</span></strong></dt> <dd> <p>Remove (one) <span class="code">{_, MonitorRef, _, _, _}</span> message, if there is one, from the caller's message queue after monitoring has been stopped.</p> <p>Calling <span class="code">demonitor(MonitorRef, [flush])</span> is equivalent to the following, but more efficient:</p> <div class="example"><pre> demonitor(MonitorRef), receive {_, MonitorRef, _, _, _} -> true after 0 -> true end</pre></div> </dd> <dt><strong><span class="code">info</span></strong></dt> <dd> <p>The returned value is one of the following:</p> <dl> <dt><strong><span class="code">true</span></strong></dt> <dd> <p>The monitor was found and removed. In this case no <span class="code">'DOWN'</span> message due to this monitor have been nor will be placed in the message queue of the caller. </p> </dd> <dt><strong><span class="code">false</span></strong></dt> <dd> <p>The monitor was not found and could not be removed. This probably because someone already has placed a <span class="code">'DOWN'</span> message corresponding to this monitor in the caller's message queue. </p> </dd> </dl> <p>If the <span class="code">info</span> option is combined with the <span class="code">flush</span> option, <span class="code">false</span> will be returned if a flush was needed; otherwise, <span class="code">true</span>. </p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>More options may be added in the future.</p> </p></div> </div> <p>Failure: <span class="code">badarg</span> if <span class="code">OptionList</span> is not a list, or if <span class="code">Option</span> is not a valid option, or the same failure as for <span class="bold_code"><a href="#demonitor-1">demonitor/1</a></span></p> </p></div> <p><a name="disconnect_node-1"></a><span class="bold_code">disconnect_node(Node) -> boolean() | ignored</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> </div></p> <div class="REFBODY"><p> <p>Forces the disconnection of a node. This will appear to the node <span class="code">Node</span> as if the local node has crashed. This BIF is mainly used in the Erlang network authentication protocols. Returns <span class="code">true</span> if disconnection succeeds, otherwise <span class="code">false</span>. If the local node is not alive, the function returns <span class="code">ignored</span>.</p> </p></div> <p><a name="display-1"><span class="bold_code">erlang:display(Term) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Prints a text representation of <span class="code">Term</span> on the standard output.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging only.</p> </p></div> </div> </p></div> <p><a name="element-2"><span class="bold_code">element(N, Tuple) -> term()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">N = 1..tuple_size(Tuple)</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Tuple = tuple()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the <span class="code">N</span>th element (numbering from 1) of <span class="code">Tuple</span>.</p> <div class="example"><pre> > <span class="bold_code">element(2, {a, b, c}).</span> b</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="erase-0"><span class="bold_code">erase() -> [{Key, Val}]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Key = Val = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the process dictionary and deletes it.</p> <div class="example"><pre> > <span class="bold_code">put(key1, {1, 2, 3}),</span> <span class="bold_code">put(key2, [a, b, c]),</span> <span class="bold_code">erase().</span> [{key1,{1,2,3}},{key2,[a,b,c]}]</pre></div> </p></div> <p><a name="erase-1"><span class="bold_code">erase(Key) -> Val | undefined</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Key = Val = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the value <span class="code">Val</span> associated with <span class="code">Key</span> and deletes it from the process dictionary. Returns <span class="code">undefined</span> if no value is associated with <span class="code">Key</span>.</p> <div class="example"><pre> > <span class="bold_code">put(key1, {merry, lambs, are, playing}),</span> <span class="bold_code">X = erase(key1),</span> <span class="bold_code">{X, erase(key1)}.</span> {{merry,lambs,are,playing},undefined}</pre></div> </p></div> <p><a name="error-1"><span class="bold_code">error(Reason)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Stops the execution of the calling process with the reason <span class="code">Reason</span>, where <span class="code">Reason</span> is any term. The actual exit reason will be <span class="code">{Reason, Where}</span>, where <span class="code">Where</span> is a list of the functions most recently called (the current function first). Since evaluating this function causes the process to terminate, it has no return value.</p> <div class="example"><pre> > <span class="bold_code">catch error(foobar).</span> {'EXIT',{foobar,[{erl_eval,do_apply,5}, {erl_eval,expr,5}, {shell,exprs,6}, {shell,eval_exprs,6}, {shell,eval_loop,3}]}}</pre></div> </p></div> <p><a name="error-2"><span class="bold_code">error(Reason, Args)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Stops the execution of the calling process with the reason <span class="code">Reason</span>, where <span class="code">Reason</span> is any term. The actual exit reason will be <span class="code">{Reason, Where}</span>, where <span class="code">Where</span> is a list of the functions most recently called (the current function first). <span class="code">Args</span> is expected to be the list of arguments for the current function; in Beam it will be used to provide the actual arguments for the current function in the <span class="code">Where</span> term. Since evaluating this function causes the process to terminate, it has no return value.</p> </p></div> <p><a name="exit-1"><span class="bold_code">exit(Reason)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Stops the execution of the calling process with the exit reason <span class="code">Reason</span>, where <span class="code">Reason</span> is any term. Since evaluating this function causes the process to terminate, it has no return value.</p> <div class="example"><pre> > <span class="bold_code">exit(foobar).</span> ** exception exit: foobar > <span class="bold_code">catch exit(foobar).</span> {'EXIT',foobar}</pre></div> </p></div> <p><a name="exit-2"><span class="bold_code">exit(Pid, Reason) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Sends an exit signal with exit reason <span class="code">Reason</span> to the process <span class="code">Pid</span>.</p> <p>The following behavior apply if <span class="code">Reason</span> is any term except <span class="code">normal</span> or <span class="code">kill</span>:</p> <p>If <span class="code">Pid</span> is not trapping exits, <span class="code">Pid</span> itself will exit with exit reason <span class="code">Reason</span>. If <span class="code">Pid</span> is trapping exits, the exit signal is transformed into a message <span class="code">{'EXIT', From, Reason}</span> and delivered to the message queue of <span class="code">Pid</span>. <span class="code">From</span> is the pid of the process which sent the exit signal. See also <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>.</p> <p>If <span class="code">Reason</span> is the atom <span class="code">normal</span>, <span class="code">Pid</span> will not exit. If it is trapping exits, the exit signal is transformed into a message <span class="code">{'EXIT', From, normal}</span> and delivered to its message queue.</p> <p>If <span class="code">Reason</span> is the atom <span class="code">kill</span>, that is if <span class="code">exit(Pid, kill)</span> is called, an untrappable exit signal is sent to <span class="code">Pid</span> which will unconditionally exit with exit reason <span class="code">killed</span>.</p> </p></div> <p><a name="external_size-1"><span class="bold_code">erlang:external_size(Term) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Calculates, without doing the encoding, the maximum byte size for a term encoded in the Erlang external term format. The following condition applies always:</p> <p> <div class="example"><pre> > <span class="bold_code">Size1 = byte_size(term_to_binary(Term)),</span> > <span class="bold_code">Size2 = erlang:external_size(Term),</span> > <span class="bold_code">true = Size1 =< Size2.</span> true </pre></div> </p> <p>This is equivalent to a call to: <div class="example"><pre>erlang:external_size(Term, []) </pre></div></p> </p></div> <p><a name="external_size-2"><span class="bold_code">erlang:external_size(Term, [Option]) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = {minor_version, Version}</span><br> </div> </div> <div class="REFBODY"><p> <p>Calculates, without doing the encoding, the maximum byte size for a term encoded in the Erlang external term format. The following condition applies always:</p> <p> <div class="example"><pre> > <span class="bold_code">Size1 = byte_size(term_to_binary(Term, Options)),</span> > <span class="bold_code">Size2 = erlang:external_size(Term, Options),</span> > <span class="bold_code">true = Size1 =< Size2.</span> true </pre></div> </p> <p>The option <span class="code">{minor_version, Version}</span> specifies how floats are encoded. See <span class="bold_code"><a href="#term_to_binary-2">term_to_binary/2</a></span> for a more detailed description. </p> </p></div> <p><a name="float-1"><span class="bold_code">float(Number) -> float()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Number = number()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a float by converting <span class="code">Number</span> to a float.</p> <div class="example"><pre> > <span class="bold_code">float(55).</span> 55.0</pre></div> <p>Allowed in guard tests.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>Note that if used on the top-level in a guard, it will test whether the argument is a floating point number; for clarity, use <span class="bold_code"><a href="#is_float-1">is_float/1</a></span> instead.</p> <p>When <span class="code">float/1</span> is used in an expression in a guard, such as '<span class="code">float(A) == 4.0</span>', it converts a number as described above.</p> </p></div> </div> </p></div> <p><a name="float_to_list-1"><span class="bold_code">float_to_list(Float) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Float = float()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Float</span>.</p> <div class="example"><pre> > <span class="bold_code">float_to_list(7.0).</span> "7.00000000000000000000e+00"</pre></div> </p></div> <p><a name="fun_info-1"></a><span class="bold_code">erlang:fun_info(Fun) -> [{Item, Info}]</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> <div class="REFTYPES"><span class="bold_code">Item = arity<br> | env<br> | index<br> | name<br> | module<br> | new_index<br> | new_uniq<br> | pid<br> | type<br> | uniq</span></div> <div class="REFTYPES"><span class="bold_code">Info = term()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns a list containing information about the fun <span class="code">Fun</span>. Each element of the list is a tuple. The order of the tuples is not defined, and more tuples may be added in a future release.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is mainly intended for debugging, but it can occasionally be useful in library functions that might need to verify, for instance, the arity of a fun.</p> </p></div> </div> <p>There are two types of funs with slightly different semantics:</p> <p>A fun created by <span class="code">fun M:F/A</span> is called an <strong>external</strong> fun. Calling it will always call the function <span class="code">F</span> with arity <span class="code">A</span> in the latest code for module <span class="code">M</span>. Note that module <span class="code">M</span> does not even need to be loaded when the fun <span class="code">fun M:F/A</span> is created.</p> <p>All other funs are called <strong>local</strong>. When a local fun is called, the same version of the code that created the fun will be called (even if newer version of the module has been loaded).</p> <p>The following elements will always be present in the list for both local and external funs:</p> <dl> <dt><strong><span class="code">{type, Type}</span></strong></dt> <dd> <p><span class="code">Type</span> is either <span class="code">local</span> or <span class="code">external</span>.</p> </dd> <dt><strong><span class="code">{module, Module}</span></strong></dt> <dd> <p><span class="code">Module</span> (an atom) is the module name.</p> <p>If <span class="code">Fun</span> is a local fun, <span class="code">Module</span> is the module in which the fun is defined.</p> <p>If <span class="code">Fun</span> is an external fun, <span class="code">Module</span> is the module that the fun refers to.</p> </dd> <dt><strong><span class="code">{name, Name}</span></strong></dt> <dd> <p><span class="code">Name</span> (an atom) is a function name.</p> <p>If <span class="code">Fun</span> is a local fun, <span class="code">Name</span> is the name of the local function that implements the fun. (This name was generated by the compiler, and is generally only of informational use. As it is a local function, it is not possible to call it directly.) If no code is currently loaded for the fun, <span class="code">[]</span> will be returned instead of an atom.</p> <p>If <span class="code">Fun</span> is an external fun, <span class="code">Name</span> is the name of the exported function that the fun refers to.</p> </dd> <dt><strong><span class="code">{arity, Arity}</span></strong></dt> <dd> <p><span class="code">Arity</span> is the number of arguments that the fun should be called with.</p> </dd> <dt><strong><span class="code">{env, Env}</span></strong></dt> <dd> <p><span class="code">Env</span> (a list) is the environment or free variables for the fun. (For external funs, the returned list is always empty.)</p> </dd> </dl> <p>The following elements will only be present in the list if <span class="code">Fun</span> is local:</p> <dl> <dt><strong><span class="code">{pid, Pid}</span></strong></dt> <dd> <p><span class="code">Pid</span> is the pid of the process that originally created the fun.</p> </dd> <dt><strong><span class="code">{index, Index}</span></strong></dt> <dd> <p><span class="code">Index</span> (an integer) is an index into the module's fun table.</p> </dd> <dt><strong><span class="code">{new_index, Index}</span></strong></dt> <dd> <p><span class="code">Index</span> (an integer) is an index into the module's fun table.</p> </dd> <dt><strong><span class="code">{new_uniq, Uniq}</span></strong></dt> <dd> <p><span class="code">Uniq</span> (a binary) is a unique value for this fun. It is calculated from the compiled code for the entire module.</p> </dd> <dt><strong><span class="code">{uniq, Uniq}</span></strong></dt> <dd> <p><span class="code">Uniq</span> (an integer) is a unique value for this fun. Starting in the R15 release, this integer is calculated from the compiled code for the entire module. Before R15, this integer was based on only the body of the fun. </p> </dd> </dl> </p></div> <p><a name="fun_info-2"><span class="bold_code">erlang:fun_info(Fun, Item) -> {Item, Info}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Fun = fun()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item, Info -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns information about <span class="code">Fun</span> as specified by <span class="code">Item</span>, in the form <span class="code">{Item,Info}</span>.</p> <p>For any fun, <span class="code">Item</span> can be any of the atoms <span class="code">module</span>, <span class="code">name</span>, <span class="code">arity</span>, <span class="code">env</span>, or <span class="code">type</span>.</p> <p>For a local fun, <span class="code">Item</span> can also be any of the atoms <span class="code">index</span>, <span class="code">new_index</span>, <span class="code">new_uniq</span>, <span class="code">uniq</span>, and <span class="code">pid</span>. For an external fun, the value of any of these items is always the atom <span class="code">undefined</span>.</p> <p>See <span class="bold_code"><a href="#fun_info-1">erlang:fun_info/1</a></span>.</p> </p></div> <p><a name="fun_to_list-1"><span class="bold_code">erlang:fun_to_list(Fun) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Fun = fun()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Fun</span>.</p> </p></div> <p><a name="function_exported-3"><span class="bold_code">erlang:function_exported(Module, Function, Arity) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Arity = arity()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if the module <span class="code">Module</span> is loaded and contains an exported function <span class="code">Function/Arity</span>; otherwise <span class="code">false</span>.</p> <p>Returns <span class="code">false</span> for any BIF (functions implemented in C rather than in Erlang).</p> </p></div> <p><a name="garbage_collect-0"><span class="bold_code">garbage_collect() -> true</span></a><br></p> <div class="REFBODY"><p> <p>Forces an immediate garbage collection of the currently executing process. The function should not be used, unless it has been noticed -- or there are good reasons to suspect -- that the spontaneous garbage collection will occur too late or not at all. Improper use may seriously degrade system performance.</p> <p>Compatibility note: In versions of OTP prior to R7, the garbage collection took place at the next context switch, not immediately. To force a context switch after a call to <span class="code">erlang:garbage_collect()</span>, it was sufficient to make any function call.</p> </p></div> <p><a name="garbage_collect-1"><span class="bold_code">garbage_collect(Pid) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Works like <span class="code">erlang:garbage_collect()</span> but on any process. The same caveats apply. Returns <span class="code">false</span> if <span class="code">Pid</span> refers to a dead process; <span class="code">true</span> otherwise.</p> </p></div> <p><a name="get-0"><span class="bold_code">get() -> [{Key, Val}]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Key = Val = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the process dictionary as a list of <span class="code">{Key, Val}</span> tuples.</p> <div class="example"><pre> > <span class="bold_code">put(key1, merry),</span> <span class="bold_code">put(key2, lambs),</span> <span class="bold_code">put(key3, {are, playing}),</span> <span class="bold_code">get().</span> [{key1,merry},{key2,lambs},{key3,{are,playing}}]</pre></div> </p></div> <p><a name="get-1"><span class="bold_code">get(Key) -> Val | undefined</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Key = Val = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the value <span class="code">Val</span>associated with <span class="code">Key</span> in the process dictionary, or <span class="code">undefined</span> if <span class="code">Key</span> does not exist.</p> <div class="example"><pre> > <span class="bold_code">put(key1, merry),</span> <span class="bold_code">put(key2, lambs),</span> <span class="bold_code">put({any, [valid, term]}, {are, playing}),</span> <span class="bold_code">get({any, [valid, term]}).</span> {are,playing}</pre></div> </p></div> <p><a name="get_cookie-0"></a><span class="bold_code">erlang:get_cookie() -> Cookie | nocookie</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Cookie = atom()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the magic cookie of the local node, if the node is alive; otherwise the atom <span class="code">nocookie</span>.</p> </p></div> <p><a name="get_keys-1"><span class="bold_code">get_keys(Val) -> [Key]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Val = Key = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of keys which are associated with the value <span class="code">Val</span> in the process dictionary.</p> <div class="example"><pre> > <span class="bold_code">put(mary, {1, 2}),</span> <span class="bold_code">put(had, {1, 2}),</span> <span class="bold_code">put(a, {1, 2}),</span> <span class="bold_code">put(little, {1, 2}),</span> <span class="bold_code">put(dog, {1, 3}),</span> <span class="bold_code">put(lamb, {1, 2}),</span> <span class="bold_code">get_keys({1, 2}).</span> [mary,had,a,little,lamb]</pre></div> </p></div> <p><a name="get_stacktrace-0"><span class="bold_code">erlang:get_stacktrace() -> [{Module, Function, Arity | Args, Location}]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Arity = arity()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Location = [{atom(),term()}]</span><br> </div> </div> <div class="REFBODY"><p> <p>Get the call stack back-trace (<strong>stacktrace</strong>) of the last exception in the calling process as a list of <span class="code">{Module,Function,Arity,Location}</span> tuples. The <span class="code">Arity</span> field in the first tuple may be the argument list of that function call instead of an arity integer, depending on the exception.</p> <p>If there has not been any exceptions in a process, the stacktrace is []. After a code change for the process, the stacktrace may also be reset to [].</p> <p>The stacktrace is the same data as the <span class="code">catch</span> operator returns, for example:</p> <p><span class="code">{'EXIT',{badarg,Stacktrace}} = catch abs(x)</span></p> <p><span class="code">Location</span> is a (possibly empty) list of two-tuples that may indicate the location in the source code of the function. The first element is an atom that describes the type of information in the second element. Currently the following items may occur:</p> <dl> <dt><strong><span class="code">file</span></strong></dt> <dd> <p>The second element of the tuple is a string (list of characters) representing the filename of the source file of the function.</p> </dd> <dt><strong><span class="code">line</span></strong></dt> <dd> <p>The second element of the tuple is the line number (an integer greater than zero) in the source file where the exception occurred or the function was called.</p> </dd> </dl> <p>See also <span class="bold_code"><a href="#error-1">erlang:error/1</a></span> and <span class="bold_code"><a href="#error-2">erlang:error/2</a></span>.</p> </p></div> <p><a name="group_leader-0"><span class="bold_code">group_leader() -> GroupLeader</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">GroupLeader = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the pid of the group leader for the process which evaluates the function.</p> <p>Every process is a member of some process group and all groups have a <strong>group leader</strong>. All IO from the group is channeled to the group leader. When a new process is spawned, it gets the same group leader as the spawning process. Initially, at system start-up, <span class="code">init</span> is both its own group leader and the group leader of all processes.</p> </p></div> <p><a name="group_leader-2"><span class="bold_code">group_leader(GroupLeader, Pid) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">GroupLeader = Pid = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Sets the group leader of <span class="code">Pid</span> to <span class="code">GroupLeader</span>. Typically, this is used when a processes started from a certain shell should have another group leader than <span class="code">init</span>.</p> <p>See also <span class="bold_code"><a href="#group_leader-0">group_leader/0</a></span>.</p> </p></div> <p><a name="halt-0"><span class="bold_code">halt()</span></a><br></p> <div class="REFBODY"><p> <p>The same as <span class="bold_code"><a href="#halt-2"><span class="code">halt(0, [])</span></a></span>.</p> <div class="example"><pre> > <span class="bold_code">halt().</span> os_prompt% </pre></div> </p></div> <p><a name="halt-1"><span class="bold_code">halt(Status)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Status = integer() >= 0 | string() | abort</span><br> </div> </div> <div class="REFBODY"><p> <p>The same as <span class="bold_code"><a href="#halt-2"><span class="code">halt(Status, [])</span></a></span>.</p> <div class="example"><pre> > <span class="bold_code">halt(17).</span> os_prompt% <span class="bold_code">echo $?</span> 17 os_prompt% </pre></div> </p></div> <p><a name="halt-2"><span class="bold_code">halt(Status, Options)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Status = integer() >= 0 | string() | abort</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = {flush,boolean()} | term()</span><br> </div> </div> <div class="REFBODY"><p> <p><span class="code">Status</span> must be a non-negative integer, a string, or the atom <span class="code">abort</span>. Halts the Erlang runtime system. Has no return value. Depending on <span class="code">Status</span>: </p> <dl> <dt><strong>integer()</strong></dt> <dd>The runtime system exits with the integer value <span class="code">Status</span> as status code to the calling environment (operating system). </dd> <dt><strong>string()</strong></dt> <dd>An erlang crash dump is produced with <span class="code">Status</span> as slogan, and then the runtime system exits with status code <span class="code">1</span>. </dd> <dt><strong><span class="code">abort</span></strong></dt> <dd> The runtime system aborts producing a core dump, if that is enabled in the operating system. </dd> </dl> <p>Note that on many platforms, only the status codes 0-255 are supported by the operating system. </p> <p>For integer <span class="code">Status</span> the Erlang runtime system closes all ports and allows async threads to finish their operations before exiting. To exit without such flushing use <span class="code">Option</span> as <span class="code">{flush,false}</span>. </p> <p>For statuses <span class="code">string()</span> and <span class="code">abort</span> the <span class="code">flush</span> option is ignored and flushing is <strong>not</strong> done. </p> </p></div> <p><a name="hash-2"><span class="bold_code">erlang:hash(Term, Range) -> Hash</span></a><br></p> <div class="REFBODY"><p> <p>Returns a hash value for <span class="code">Term</span> within the range <span class="code">1..Range</span>. The allowed range is 1..2^27-1.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is deprecated as the hash value may differ on different architectures. Also the hash values for integer terms larger than 2^27 as well as large binaries are very poor. The BIF is retained for backward compatibility reasons (it may have been used to hash records into a file), but all new code should use one of the BIFs <span class="code">erlang:phash/2</span> or <span class="code">erlang:phash2/1,2</span> instead.</p> </p></div> </div> </p></div> <p><a name="hd-1"><span class="bold_code">hd(List) -> term()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">List = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the head of <span class="code">List</span>, that is, the first element.</p> <div class="example"><pre> > <span class="bold_code">hd([1,2,3,4,5]).</span> 1</pre></div> <p>Allowed in guard tests.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">List</span> is the empty list [].</p> </p></div> <p><a name="hibernate-3"><span class="bold_code">erlang:hibernate(Module, Function, Args)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Puts the calling process into a wait state where its memory allocation has been reduced as much as possible, which is useful if the process does not expect to receive any messages in the near future.</p> <p>The process will be awaken when a message is sent to it, and control will resume in <span class="code">Module:Function</span> with the arguments given by <span class="code">Args</span> with the call stack emptied, meaning that the process will terminate when that function returns. Thus <span class="code">erlang:hibernate/3</span> will never return to its caller.</p> <p>If the process has any message in its message queue, the process will be awaken immediately in the same way as described above.</p> <p>In more technical terms, what <span class="code">erlang:hibernate/3</span> does is the following. It discards the call stack for the process. Then it garbage collects the process. After the garbage collection, all live data is in one continuous heap. The heap is then shrunken to the exact same size as the live data which it holds (even if that size is less than the minimum heap size for the process).</p> <p>If the size of the live data in the process is less than the minimum heap size, the first garbage collection occurring after the process has been awaken will ensure that the heap size is changed to a size not smaller than the minimum heap size.</p> <p>Note that emptying the call stack means that any surrounding <span class="code">catch</span> is removed and has to be re-inserted after hibernation. One effect of this is that processes started using <span class="code">proc_lib</span> (also indirectly, such as <span class="code">gen_server</span> processes), should use <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','proc_lib.html#hibernate-3');">proc_lib:hibernate/3</a></span> instead to ensure that the exception handler continues to work when the process wakes up.</p> </p></div> <p><a name="integer_to_list-1"><span class="bold_code">integer_to_list(Integer) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Integer = integer()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Integer</span>.</p> <div class="example"><pre> > <span class="bold_code">integer_to_list(77).</span> "77"</pre></div> </p></div> <p><a name="integer_to_list-2"></a><span class="bold_code">integer_to_list(Integer, Base) -> string()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Integer = integer()</span></div> <div class="REFTYPES"><span class="bold_code">Base = 2..36</span></div> </div></p> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Integer</span> in base <span class="code">Base</span>.</p> <div class="example"><pre> > <span class="bold_code">integer_to_list(1023, 16).</span> "3FF"</pre></div> </p></div> <p><a name="iolist_to_binary-1"><span class="bold_code">iolist_to_binary(IoListOrBinary) -> binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">IoListOrBinary = iolist() | binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a binary which is made from the integers and binaries in <span class="code">IoListOrBinary</span>.</p> <div class="example"><pre> > <span class="bold_code">Bin1 = <<1,2,3>>.</span> <<1,2,3>> > <span class="bold_code">Bin2 = <<4,5>>.</span> <<4,5>> > <span class="bold_code">Bin3 = <<6>>.</span> <<6>> > <span class="bold_code">iolist_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).</span> <<1,2,3,1,2,3,4,5,4,6>></pre></div> </p></div> <p><a name="iolist_size-1"><span class="bold_code">iolist_size(Item) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Item = iolist() | binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer which is the size in bytes of the binary that would be the result of <span class="code">iolist_to_binary(Item)</span>.</p> <div class="example"><pre> > <span class="bold_code">iolist_size([1,2|<<3,4>>]).</span> 4</pre></div> </p></div> <p><a name="is_alive-0"><span class="bold_code">is_alive() -> boolean()</span></a><br></p> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if the local node is alive; that is, if the node can be part of a distributed system. Otherwise, it returns <span class="code">false</span>.</p> </p></div> <p><a name="is_atom-1"><span class="bold_code">is_atom(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is an atom; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_binary-1"><span class="bold_code">is_binary(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a binary; otherwise returns <span class="code">false</span>.</p> <p>A binary always contains a complete number of bytes.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_bitstring-1"><span class="bold_code">is_bitstring(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a bitstring (including a binary); otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_boolean-1"><span class="bold_code">is_boolean(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is either the atom <span class="code">true</span> or the atom <span class="code">false</span> (i.e. a boolean); otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_builtin-3"><span class="bold_code">erlang:is_builtin(Module, Function, Arity) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Arity = arity()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Module:Function/Arity</span> is a BIF implemented in C; otherwise returns <span class="code">false</span>. This BIF is useful for builders of cross reference tools.</p> </p></div> <p><a name="is_float-1"><span class="bold_code">is_float(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a floating point number; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_function-1"><span class="bold_code">is_function(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a fun; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_function-2"><span class="bold_code">is_function(Term, Arity) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Arity = arity()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a fun that can be applied with <span class="code">Arity</span> number of arguments; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>Currently, <span class="code">is_function/2</span> will also return <span class="code">true</span> if the first argument is a tuple fun (a tuple containing two atoms). In a future release, tuple funs will no longer be supported and <span class="code">is_function/2</span> will return <span class="code">false</span> if given a tuple fun.</p> </p></div> </div> </p></div> <p><a name="is_integer-1"><span class="bold_code">is_integer(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is an integer; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_list-1"><span class="bold_code">is_list(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a list with zero or more elements; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_number-1"><span class="bold_code">is_number(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is either an integer or a floating point number; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_pid-1"><span class="bold_code">is_pid(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a pid (process identifier); otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_port-1"><span class="bold_code">is_port(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a port identifier; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_process_alive-1"><span class="bold_code">is_process_alive(Pid) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p> <span class="code">Pid</span> must refer to a process at the local node. Returns <span class="code">true</span> if the process exists and is alive, that is, is not exiting and has not exited. Otherwise, returns <span class="code">false</span>. </p> </p></div> <p><a name="is_record-2"><span class="bold_code">is_record(Term, RecordTag) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">RecordTag = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a tuple and its first element is <span class="code">RecordTag</span>. Otherwise, returns <span class="code">false</span>.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>Normally the compiler treats calls to <span class="code">is_record/2</span> specially. It emits code to verify that <span class="code">Term</span> is a tuple, that its first element is <span class="code">RecordTag</span>, and that the size is correct. However, if the <span class="code">RecordTag</span> is not a literal atom, the <span class="code">is_record/2</span> BIF will be called instead and the size of the tuple will not be verified.</p> </p></div> </div> <p>Allowed in guard tests, if <span class="code">RecordTag</span> is a literal atom.</p> </p></div> <p><a name="is_record-3"><span class="bold_code">is_record(Term, RecordTag, Size) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">RecordTag = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Size = integer()</span><br> </div> </div> <div class="REFBODY"><p> <p><span class="code">RecordTag</span> must be an atom. Returns <span class="code">true</span> if <span class="code">Term</span> is a tuple, its first element is <span class="code">RecordTag</span>, and its size is <span class="code">Size</span>. Otherwise, returns <span class="code">false</span>.</p> <p>Allowed in guard tests, provided that <span class="code">RecordTag</span> is a literal atom and <span class="code">Size</span> is a literal integer.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>This BIF is documented for completeness. In most cases <span class="code">is_record/2</span> should be used.</p> </p></div> </div> </p></div> <p><a name="is_reference-1"><span class="bold_code">is_reference(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a reference; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="is_tuple-1"><span class="bold_code">is_tuple(Term) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if <span class="code">Term</span> is a tuple; otherwise returns <span class="code">false</span>.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="length-1"><span class="bold_code">length(List) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">List = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the length of <span class="code">List</span>.</p> <div class="example"><pre> > <span class="bold_code">length([1,2,3,4,5,6,7,8,9]).</span> 9</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="link-1"><span class="bold_code">link(Pid) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid() | port()</span><br> </div> </div> <div class="REFBODY"><p> <p>Creates a link between the calling process and another process (or port) <span class="code">Pid</span>, if there is not such a link already. If a process attempts to create a link to itself, nothing is done. Returns <span class="code">true</span>.</p> <p>If <span class="code">Pid</span> does not exist, the behavior of the BIF depends on if the calling process is trapping exits or not (see <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>):</p> <ul> <li>If the calling process is not trapping exits, and checking <span class="code">Pid</span> is cheap -- that is, if <span class="code">Pid</span> is local -- <span class="code">link/1</span> fails with reason <span class="code">noproc</span>.</li> <li>Otherwise, if the calling process is trapping exits, and/or <span class="code">Pid</span> is remote, <span class="code">link/1</span> returns <span class="code">true</span>, but an exit signal with reason <span class="code">noproc</span> is sent to the calling process.</li> </ul> </p></div> <p><a name="list_to_atom-1"><span class="bold_code">list_to_atom(String) -> atom()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">String = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the atom whose text representation is <span class="code">String</span>.</p> <div class="example"><pre> > <span class="bold_code">list_to_atom("Erlang").</span> 'Erlang'</pre></div> </p></div> <p><a name="list_to_binary-1"><span class="bold_code">list_to_binary(IoList) -> binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">IoList = iolist()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a binary which is made from the integers and binaries in <span class="code">IoList</span>.</p> <div class="example"><pre> > <span class="bold_code">Bin1 = <<1,2,3>>.</span> <<1,2,3>> > <span class="bold_code">Bin2 = <<4,5>>.</span> <<4,5>> > <span class="bold_code">Bin3 = <<6>>.</span> <<6>> > <span class="bold_code">list_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).</span> <<1,2,3,1,2,3,4,5,4,6>></pre></div> </p></div> <p><a name="list_to_bitstring-1"><span class="bold_code">list_to_bitstring(BitstringList) -> bitstring()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">BitstringList = [BitstringList | bitstring() | char()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a bitstring which is made from the integers and bitstrings in <span class="code">BitstringList</span>. (The last tail in <span class="code">BitstringList</span> is allowed to be a bitstring.)</p> <div class="example"><pre> > <span class="bold_code">Bin1 = <<1,2,3>>.</span> <<1,2,3>> > <span class="bold_code">Bin2 = <<4,5>>.</span> <<4,5>> > <span class="bold_code">Bin3 = <<6,7:4,>>.</span> <<6>> > <span class="bold_code">list_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).</span> <<1,2,3,1,2,3,4,5,4,6,7:46>></pre></div> </p></div> <p><a name="list_to_existing_atom-1"><span class="bold_code">list_to_existing_atom(String) -> atom()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">String = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the atom whose text representation is <span class="code">String</span>, but only if there already exists such atom.</p> <p>Failure: <span class="code">badarg</span> if there does not already exist an atom whose text representation is <span class="code">String</span>.</p> </p></div> <p><a name="list_to_float-1"><span class="bold_code">list_to_float(String) -> float()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">String = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the float whose text representation is <span class="code">String</span>.</p> <div class="example"><pre> > <span class="bold_code">list_to_float("2.2017764e+0").</span> 2.2017764</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">String</span> contains a bad representation of a float.</p> </p></div> <p><a name="list_to_integer-1"><span class="bold_code">list_to_integer(String) -> integer()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">String = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer whose text representation is <span class="code">String</span>.</p> <div class="example"><pre> > <span class="bold_code">list_to_integer("123").</span> 123</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">String</span> contains a bad representation of an integer.</p> </p></div> <p><a name="list_to_integer-2"></a><span class="bold_code">list_to_integer(String, Base) -> integer()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">String = string()</span></div> <div class="REFTYPES"><span class="bold_code">Base = 2..36</span></div> </div></p> <div class="REFBODY"><p> <p>Returns an integer whose text representation in base <span class="code">Base</span> is <span class="code">String</span>.</p> <div class="example"><pre> > <span class="bold_code">list_to_integer("3FF", 16).</span> 1023</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">String</span> contains a bad representation of an integer.</p> </p></div> <p><a name="list_to_pid-1"><span class="bold_code">list_to_pid(String) -> pid()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">String = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a pid whose text representation is <span class="code">String</span>.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.</p> </p></div> </div> <div class="example"><pre> > <span class="bold_code">list_to_pid("<0.4.1>").</span> <0.4.1></pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">String</span> contains a bad representation of a pid.</p> </p></div> <p><a name="list_to_tuple-1"><span class="bold_code">list_to_tuple(List) -> tuple()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">List = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a tuple which corresponds to <span class="code">List</span>. <span class="code">List</span> can contain any Erlang terms.</p> <div class="example"><pre> > <span class="bold_code">list_to_tuple([share, ['Ericsson_B', 163]]).</span> {share, ['Ericsson_B', 163]}</pre></div> </p></div> <p><a name="load_module-2"><span class="bold_code">load_module(Module, Binary) -> {module, Module} | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Binary = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = badfile | not_purged | badfile</span><br> </div> </div> <div class="REFBODY"><p> <p>If <span class="code">Binary</span> contains the object code for the module <span class="code">Module</span>, this BIF loads that object code. Also, if the code for the module <span class="code">Module</span> already exists, all export references are replaced so they point to the newly loaded code. The previously loaded code is kept in the system as old code, as there may still be processes which are executing that code. It returns either <span class="code">{module, Module}</span>, or <span class="code">{error, Reason}</span> if loading fails. <span class="code">Reason</span> is one of the following:</p> <dl> <dt><strong><span class="code">badfile</span></strong></dt> <dd> <p>The object code in <span class="code">Binary</span> has an incorrect format.</p> </dd> <dt><strong><span class="code">not_purged</span></strong></dt> <dd> <p><span class="code">Binary</span> contains a module which cannot be loaded because old code for this module already exists.</p> </dd> <dt><strong><span class="code">badfile</span></strong></dt> <dd> <p>The object code contains code for another module than <span class="code">Module</span></p> </dd> </dl> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for the code server (see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>) and should not be used elsewhere.</p> </p></div> </div> </p></div> <p><a name="load_nif-2"><span class="bold_code">erlang:load_nif(Path, LoadInfo) -> ok | {error, {Reason, Text}}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Path = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">LoadInfo = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = load_failed | bad_lib | load | reload | upgrade | old_code</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Text = string()</span><br> </div> </div> <div class="REFBODY"><p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>In releases older than OTP R14B, NIFs were an experimental feature. Versions of OTP older than R14B might have different and possibly incompatible NIF semantics and interfaces. For example, in R13B03 the return value on failure was <span class="code">{error,Reason,Text}</span>.</p> </p></div> </div> <p>Loads and links a dynamic library containing native implemented functions (NIFs) for a module. <span class="code">Path</span> is a file path to the sharable object/dynamic library file minus the OS-dependent file extension (.so for Unix and .dll for Windows). See <span class="bold_code"><a href="erl_nif.html">erl_nif</a></span> on how to implement a NIF library.</p> <p><span class="code">LoadInfo</span> can be any term. It will be passed on to the library as part of the initialization. A good practice is to include a module version number to support future code upgrade scenarios.</p> <p>The call to <span class="code">load_nif/2</span> must be made <strong>directly</strong> from the Erlang code of the module that the NIF library belongs to.</p> <p>It returns either <span class="code">ok</span>, or <span class="code">{error,{Reason,Text}}</span> if loading fails. <span class="code">Reason</span> is one of the atoms below, while <span class="code">Text</span> is a human readable string that may give some more information about the failure.</p> <dl> <dt><strong><span class="code">load_failed</span></strong></dt> <dd> <p>The OS failed to load the NIF library.</p> </dd> <dt><strong><span class="code">bad_lib</span></strong></dt> <dd> <p>The library did not fulfil the requirements as a NIF library of the calling module.</p> </dd> <dt><strong><span class="code">load | reload | upgrade</span></strong></dt> <dd> <p>The corresponding library callback was not successful.</p> </dd> <dt><strong><span class="code">old_code</span></strong></dt> <dd> <p>The call to <span class="code">load_nif/2</span> was made from the old code of a module that has been upgraded. This is not allowed.</p> </dd> </dl> </p></div> <p><a name="loaded-0"><span class="bold_code">erlang:loaded() -> [Module]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of all loaded Erlang modules (current and/or old code), including preloaded modules.</p> <p>See also <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>.</p> </p></div> <p><a name="localtime-0"><span class="bold_code">erlang:localtime() -> DateTime</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">DateTime = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-datetime');">calendar:datetime()</a></span></span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the current local date and time <span class="code">{{Year, Month, Day}, {Hour, Minute, Second}}</span>.</p> <p>The time zone and daylight saving time correction depend on the underlying OS.</p> <div class="example"><pre> > <span class="bold_code">erlang:localtime().</span> {{1996,11,6},{14,45,17}}</pre></div> </p></div> <p><a name="localtime_to_universaltime-1"></a><span class="bold_code">erlang:localtime_to_universaltime(Localtime :: {Date1, Time1}) -><br> {Date2, Time2}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Date1 = Date2 = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-date');">calendar:date()</a></span></span></div> <div class="REFTYPES"><span class="bold_code"></span></div> <div class="REFTYPES"><span class="bold_code">Time1 = Time2 = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-time');">calendar:time()</a></span></span></div> <div class="REFTYPES"><span class="bold_code"></span></div> </div></p> <div class="REFBODY"><p> <p>Converts local date and time to Universal Time Coordinated (UTC), if this is supported by the underlying OS. Otherwise, no conversion is done and <span class="code">{Date1, Time1}</span> is returned.</p> <div class="example"><pre> > <span class="bold_code">erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}).</span> {{1996,11,6},{13,45,17}}</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">Date1</span> or <span class="code">Time1</span> do not denote a valid date or time.</p> </p></div> <p><a name="localtime_to_universaltime-2"><span class="bold_code">erlang:localtime_to_universaltime({Date1, Time1}, IsDst) -> {Date2, Time2}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Date1 = Date2 = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-date');">calendar:date()</a></span></span><br> </div> <div class="REFTYPES"> <span class="bold_code">Time1 = Time2 = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-time');">calendar:time()</a></span></span><br> </div> <div class="REFTYPES"> <span class="bold_code">IsDst = true | false | undefined</span><br> </div> </div> <div class="REFBODY"><p> <p>Converts local date and time to Universal Time Coordinated (UTC) just like <span class="code">erlang:localtime_to_universaltime/1</span>, but the caller decides if daylight saving time is active or not.</p> <p>If <span class="code">IsDst == true</span> the <span class="code">{Date1, Time1}</span> is during daylight saving time, if <span class="code">IsDst == false</span> it is not, and if <span class="code">IsDst == undefined</span> the underlying OS may guess, which is the same as calling <span class="code">erlang:localtime_to_universaltime({Date1, Time1})</span>.</p> <div class="example"><pre> > <span class="bold_code">erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, true).</span> {{1996,11,6},{12,45,17}} > <span class="bold_code">erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, false).</span> {{1996,11,6},{13,45,17}} > <span class="bold_code">erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, undefined).</span> {{1996,11,6},{13,45,17}}</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">Date1</span> or <span class="code">Time1</span> do not denote a valid date or time.</p> </p></div> <p><a name="make_ref-0"><span class="bold_code">make_ref() -> reference()</span></a><br></p> <div class="REFBODY"><p> <p>Returns an almost unique reference.</p> <p>The returned reference will re-occur after approximately 2^82 calls; therefore it is unique enough for practical purposes.</p> <div class="example"><pre> > <span class="bold_code">make_ref().</span> #Ref<0.0.0.135></pre></div> </p></div> <p><a name="make_tuple-2"><span class="bold_code">erlang:make_tuple(Arity, InitialValue) -> tuple()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Arity = arity()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InitialValue = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a new tuple of the given <span class="code">Arity</span>, where all elements are <span class="code">InitialValue</span>.</p> <div class="example"><pre> > <span class="bold_code">erlang:make_tuple(4, []).</span> {[],[],[],[]}</pre></div> </p></div> <p><a name="make_tuple-3"><span class="bold_code">erlang:make_tuple(Arity, Default, InitList) -> tuple()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Arity = arity()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Default = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InitList = [{Position,term()}]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Position = integer()</span><br> </div> </div> <div class="REFBODY"><p> <p><span class="code">erlang:make_tuple</span> first creates a tuple of size <span class="code">Arity</span> where each element has the value <span class="code">Default</span>. It then fills in values from <span class="code">InitList</span>. Each list element in <span class="code">InitList</span> must be a two-tuple where the first element is a position in the newly created tuple and the second element is any term. If a position occurs more than once in the list, the term corresponding to last occurrence will be used.</p> <div class="example"><pre> > <span class="bold_code">erlang:make_tuple(5, [], [{2,ignored},{5,zz},{2,aa}]).</span> {{[],aa,[],[],zz}</pre></div> </p></div> <p><a name="max-2"></a><span class="bold_code">max(Term1, Term2) -> Maximum</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Term1 = Term2 = Maximum = term()</span></div> <div class="REFTYPES"><span class="bold_code"></span></div> <div class="REFTYPES"><span class="bold_code"></span></div> </div></p> <div class="REFBODY"><p> <p>Return the largest of <span class="code">Term1</span> and <span class="code">Term2</span>; if the terms compare equal, <span class="code">Term1</span> will be returned.</p> </p></div> <p><a name="md5-1"><span class="bold_code">erlang:md5(Data) -> Digest</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Digest = binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Computes an <span class="code">MD5</span> message digest from <span class="code">Data</span>, where the length of the digest is 128 bits (16 bytes). <span class="code">Data</span> is a binary or a list of small integers and binaries.</p> <p>See The MD5 Message Digest Algorithm (RFC 1321) for more information about MD5.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p><p>The MD5 Message Digest Algorithm is <strong>not</strong> considered safe for code-signing or software integrity purposes.</p></p></div> </div> </p></div> <p><a name="md5_final-1"><span class="bold_code">erlang:md5_final(Context) -> Digest</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Context = Digest = binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Finishes the update of an MD5 <span class="code">Context</span> and returns the computed <span class="code">MD5</span> message digest.</p> </p></div> <p><a name="md5_init-0"><span class="bold_code">erlang:md5_init() -> Context</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Context = binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Creates an MD5 context, to be used in subsequent calls to <span class="code">md5_update/2</span>.</p> </p></div> <p><a name="md5_update-2"><span class="bold_code">erlang:md5_update(Context, Data) -> NewContext</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Context = NewContext = binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Updates an MD5 <span class="code">Context</span> with <span class="code">Data</span>, and returns a <span class="code">NewContext</span>.</p> </p></div> <p><a name="memory-0"><span class="bold_code">erlang:memory() -> [{Type, Size}]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Type, Size -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list containing information about memory dynamically allocated by the Erlang emulator. Each element of the list is a tuple <span class="code">{Type, Size}</span>. The first element <span class="code">Type</span>is an atom describing memory type. The second element <span class="code">Size</span>is memory size in bytes. A description of each memory type follows:</p> <dl> <dt><strong><span class="code">total</span></strong></dt> <dd> <p>The total amount of memory currently allocated, which is the same as the sum of memory size for <span class="code">processes</span> and <span class="code">system</span>.</p> </dd> <dt><strong><span class="code">processes</span></strong></dt> <dd> <p>The total amount of memory currently allocated by the Erlang processes.</p> </dd> <dt><strong><span class="code">processes_used</span></strong></dt> <dd> <p>The total amount of memory currently used by the Erlang processes.</p> <p>This memory is part of the memory presented as <span class="code">processes</span> memory.</p> </dd> <dt><strong><span class="code">system</span></strong></dt> <dd> <p>The total amount of memory currently allocated by the emulator that is not directly related to any Erlang process.</p> <p>Memory presented as <span class="code">processes</span> is not included in this memory.</p> </dd> <dt><strong><span class="code">atom</span></strong></dt> <dd> <p>The total amount of memory currently allocated for atoms.</p> <p>This memory is part of the memory presented as <span class="code">system</span> memory.</p> </dd> <dt><strong><span class="code">atom_used</span></strong></dt> <dd> <p>The total amount of memory currently used for atoms.</p> <p>This memory is part of the memory presented as <span class="code">atom</span> memory.</p> </dd> <dt><strong><span class="code">binary</span></strong></dt> <dd> <p>The total amount of memory currently allocated for binaries.</p> <p>This memory is part of the memory presented as <span class="code">system</span> memory.</p> </dd> <dt><strong><span class="code">code</span></strong></dt> <dd> <p>The total amount of memory currently allocated for Erlang code.</p> <p>This memory is part of the memory presented as <span class="code">system</span> memory.</p> </dd> <dt><strong><span class="code">ets</span></strong></dt> <dd> <p>The total amount of memory currently allocated for ets tables.</p> <p>This memory is part of the memory presented as <span class="code">system</span> memory.</p> </dd> <dt><strong><span class="code">maximum</span></strong></dt> <dd> <p>The maximum total amount of memory allocated since the emulator was started.</p> <p>This tuple is only present when the emulator is run with instrumentation.</p> <p>For information on how to run the emulator with instrumentation see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','tools','instrument.html');">instrument(3)</a></span> and/or <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html');">erl(1)</a></span>.</p> </dd> <dt><strong><span class="code">low</span></strong></dt> <dd> <p>Only on 64-bit halfword emulator.</p> <p>The total amount of memory allocated in low memory areas that are restricted to less than 4 Gb even though the system may have more physical memory.</p> <p>May be removed in future releases of halfword emulator.</p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The <span class="code">system</span> value is not complete. Some allocated memory that should be part of the <span class="code">system</span> value are not.</p> <p>When the emulator is run with instrumentation, the <span class="code">system</span> value is more accurate, but memory directly allocated by <span class="code">malloc</span> (and friends) are still not part of the <span class="code">system</span> value. Direct calls to <span class="code">malloc</span> are only done from OS specific runtime libraries and perhaps from user implemented Erlang drivers that do not use the memory allocation functions in the driver interface.</p> <p>Since the <span class="code">total</span> value is the sum of <span class="code">processes</span> and <span class="code">system</span> the error in <span class="code">system</span> will propagate to the <span class="code">total</span> value.</p> <p>The different amounts of memory that are summed are <strong>not</strong> gathered atomically which also introduce an error in the result.</p> </p></div> </div> <p>The different values has the following relation to each other. Values beginning with an uppercase letter is not part of the result.</p> <div class="example"><pre> total = processes + system processes = processes_used + ProcessesNotUsed system = atom + binary + code + ets + OtherSystem atom = atom_used + AtomNotUsed RealTotal = processes + RealSystem RealSystem = system + MissedSystem</pre></div> <p>More tuples in the returned list may be added in the future.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The <span class="code">total</span> value is supposed to be the total amount of memory dynamically allocated by the emulator. Shared libraries, the code of the emulator itself, and the emulator stack(s) are not supposed to be included. That is, the <span class="code">total</span> value is <strong>not</strong> supposed to be equal to the total size of all pages mapped to the emulator. Furthermore, due to fragmentation and pre-reservation of memory areas, the size of the memory segments which contain the dynamically allocated memory blocks can be substantially larger than the total size of the dynamically allocated memory blocks.</p> </p></div> </div> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p> Since erts version 5.6.4 <span class="code">erlang:memory/0</span> requires that all <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html');">erts_alloc(3)</a></span> allocators are enabled (default behaviour). </p> </p></div> </div> <p>Failure:</p> <dl> <dt><strong><span class="code">notsup</span></strong></dt> <dd> If an <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html');">erts_alloc(3)</a></span> allocator has been disabled. </dd> </dl> </p></div> <p><a name="memory-1"><span class="bold_code">erlang:memory(Type | [Type]) -> Size | [{Type, Size}]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Type, Size -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the memory size in bytes allocated for memory of type <span class="code">Type</span>. The argument can also be given as a list of <span class="code">Type</span> atoms, in which case a corresponding list of <span class="code">{Type, Size}</span> tuples is returned.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p> Since erts version 5.6.4 <span class="code">erlang:memory/1</span> requires that all <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html');">erts_alloc(3)</a></span> allocators are enabled (default behaviour). </p> </p></div> </div> <p>Failures:</p> <dl> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Type</span> is not one of the memory types listed in the documentation of <span class="bold_code"><a href="#memory-0">erlang:memory/0</a></span>. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">maximum</span> is passed as <span class="code">Type</span> and the emulator is not run in instrumented mode. </dd> <dt><strong><span class="code">notsup</span></strong></dt> <dd> If an <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html');">erts_alloc(3)</a></span> allocator has been disabled. </dd> </dl> <p>See also <span class="bold_code"><a href="#memory-0">erlang:memory/0</a></span>.</p> </p></div> <p><a name="min-2"></a><span class="bold_code">min(Term1, Term2) -> Minimum</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Term1 = Term2 = Minimum = term()</span></div> <div class="REFTYPES"><span class="bold_code"></span></div> <div class="REFTYPES"><span class="bold_code"></span></div> </div></p> <div class="REFBODY"><p> <p>Return the smallest of <span class="code">Term1</span> and <span class="code">Term2</span>; if the terms compare equal, <span class="code">Term1</span> will be returned.</p> </p></div> <p><a name="module_loaded-1"><span class="bold_code">module_loaded(Module) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">true</span> if the module <span class="code">Module</span> is loaded, otherwise returns <span class="code">false</span>. It does not attempt to load the module.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for the code server (see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>) and should not be used elsewhere.</p> </p></div> </div> </p></div> <p><a name="monitor-2"><span class="bold_code">monitor(Type, Item) -> MonitorRef</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Type = process</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item = pid() | {RegName, Node} | RegName</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> RegName = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Node = node()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MonitorRef = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p>The calling process starts monitoring <span class="code">Item</span> which is an object of type <span class="code">Type</span>.</p> <p>Currently only processes can be monitored, i.e. the only allowed <span class="code">Type</span> is <span class="code">process</span>, but other types may be allowed in the future.</p> <p><span class="code">Item</span> can be:</p> <dl> <dt><strong><span class="code">pid()</span></strong></dt> <dd> <p>The pid of the process to monitor.</p> </dd> <dt><strong><span class="code">{RegName, Node}</span></strong></dt> <dd> <p>A tuple consisting of a registered name of a process and a node name. The process residing on the node <span class="code">Node</span> with the registered name <span class="code">RegName</span> will be monitored.</p> </dd> <dt><strong><span class="code">RegName</span></strong></dt> <dd> <p>The process locally registered as <span class="code">RegName</span> will be monitored.</p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>When a process is monitored by registered name, the process that has the registered name at the time when <span class="code">monitor/2</span> is called will be monitored. The monitor will not be effected, if the registered name is unregistered.</p> </p></div> </div> <p>A <span class="code">'DOWN'</span> message will be sent to the monitoring process if <span class="code">Item</span> dies, if <span class="code">Item</span> does not exist, or if the connection is lost to the node which <span class="code">Item</span> resides on. A <span class="code">'DOWN'</span> message has the following pattern:</p> <div class="example"><pre> {'DOWN', MonitorRef, Type, Object, Info}</pre></div> <p>where <span class="code">MonitorRef</span> and <span class="code">Type</span> are the same as described above, and:</p> <dl> <dt><strong><span class="code">Object</span></strong></dt> <dd> <p>A reference to the monitored object:</p> <ul> <li>the pid of the monitored process, if <span class="code">Item</span> was specified as a pid.</li> <li> <span class="code">{RegName, Node}</span>, if <span class="code">Item</span> was specified as <span class="code">{RegName, Node}</span>.</li> <li> <span class="code">{RegName, Node}</span>, if <span class="code">Item</span> was specified as <span class="code">RegName</span>. <span class="code">Node</span> will in this case be the name of the local node (<span class="code">node()</span>).</li> </ul> </dd> <dt><strong><span class="code">Info</span></strong></dt> <dd> <p>Either the exit reason of the process, <span class="code">noproc</span> (non-existing process), or <span class="code">noconnection</span> (no connection to <span class="code">Node</span>).</p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>If/when <span class="code">monitor/2</span> is extended (e.g. to handle other item types than <span class="code">process</span>), other possible values for <span class="code">Object</span>, and <span class="code">Info</span> in the <span class="code">'DOWN'</span> message will be introduced.</p> </p></div> </div> <p>The monitoring is turned off either when the <span class="code">'DOWN'</span> message is sent, or when <span class="bold_code"><a href="#demonitor-1">demonitor/1</a></span> is called.</p> <p>If an attempt is made to monitor a process on an older node (where remote process monitoring is not implemented or one where remote process monitoring by registered name is not implemented), the call fails with <span class="code">badarg</span>.</p> <p>Making several calls to <span class="code">monitor/2</span> for the same <span class="code">Item</span> is not an error; it results in as many, completely independent, monitorings.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The format of the <span class="code">'DOWN'</span> message changed in the 5.2 version of the emulator (OTP release R9B) for monitor <strong>by registered name</strong>. The <span class="code">Object</span> element of the <span class="code">'DOWN'</span> message could in earlier versions sometimes be the pid of the monitored process and sometimes be the registered name. Now the <span class="code">Object</span> element is always a tuple consisting of the registered name and the node name. Processes on new nodes (emulator version 5.2 or greater) will always get <span class="code">'DOWN'</span> messages on the new format even if they are monitoring processes on old nodes. Processes on old nodes will always get <span class="code">'DOWN'</span> messages on the old format.</p> </p></div> </div> </p></div> <p><a name="monitor_node-2"><span class="bold_code">monitor_node(Node, Flag) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Node = node()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Flag = boolean()</span><br> </div> </div> <div class="REFBODY"><p> <p>Monitors the status of the node <span class="code">Node</span>. If <span class="code">Flag</span> is <span class="code">true</span>, monitoring is turned on; if <span class="code">Flag</span> is <span class="code">false</span>, monitoring is turned off.</p> <p>Making several calls to <span class="code">monitor_node(Node, true)</span> for the same <span class="code">Node</span> is not an error; it results in as many, completely independent, monitorings.</p> <p>If <span class="code">Node</span> fails or does not exist, the message <span class="code">{nodedown, Node}</span> is delivered to the process. If a process has made two calls to <span class="code">monitor_node(Node, true)</span> and <span class="code">Node</span> terminates, two <span class="code">nodedown</span> messages are delivered to the process. If there is no connection to <span class="code">Node</span>, there will be an attempt to create one. If this fails, a <span class="code">nodedown</span> message is delivered.</p> <p>Nodes connected through hidden connections can be monitored as any other node.</p> <p>Failure: <span class="code">badarg</span>if the local node is not alive.</p> </p></div> <p><a name="monitor_node-3"><span class="bold_code">erlang:monitor_node(Node, Flag, Options) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Node = node()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Flag = boolean()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = allow_passive_connect</span><br> </div> </div> <div class="REFBODY"><p> <p>Behaves as <span class="code">monitor_node/2</span> except that it allows an extra option to be given, namely <span class="code">allow_passive_connect</span>. The option allows the BIF to wait the normal net connection timeout for the <strong>monitored node</strong> to connect itself, even if it cannot be actively connected from this node (i.e. it is blocked). The state where this might be useful can only be achieved by using the kernel option <span class="code">dist_auto_connect once</span>. If that kernel option is not used, the <span class="code">allow_passive_connect</span> option has no effect.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The <span class="code">allow_passive_connect</span> option is used internally and is seldom needed in applications where the network topology and the kernel options in effect is known in advance.</p> </p></div> </div> <p>Failure: <span class="code">badarg</span> if the local node is not alive or the option list is malformed.</p> </p></div> <p><a name="nif_error-1"><span class="bold_code">erlang:nif_error(Reason)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Works exactly like <span class="bold_code"><a href="#error-1">erlang:error/1</a></span>, but Dialyzer thinks that this BIF will return an arbitrary term. When used in a stub function for a NIF to generate an exception when the NIF library is not loaded, Dialyzer will not generate false warnings.</p> </p></div> <p><a name="nif_error-2"><span class="bold_code">erlang:nif_error(Reason, Args)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Works exactly like <span class="bold_code"><a href="#error-2">erlang:error/2</a></span>, but Dialyzer thinks that this BIF will return an arbitrary term. When used in a stub function for a NIF to generate an exception when the NIF library is not loaded, Dialyzer will not generate false warnings.</p> </p></div> <p><a name="node-0"><span class="bold_code">node() -> Node</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Node = node()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the name of the local node. If the node is not alive, <span class="code">nonode@nohost</span> is returned instead.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="node-1"><span class="bold_code">node(Arg) -> Node</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Arg = pid() | port() | reference()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Node = node()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the node where <span class="code">Arg</span> is located. <span class="code">Arg</span> can be a pid, a reference, or a port. If the local node is not alive, <span class="code">nonode@nohost</span> is returned.</p> <p>Allowed in guard tests.</p> </p></div> <p><a name="nodes-0"></a><span class="bold_code">nodes() -> Nodes</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Nodes = [node()]</span></div> </div></p> <div class="REFBODY"><p> <p>Returns a list of all visible nodes in the system, excluding the local node. Same as <span class="code">nodes(visible)</span>.</p> </p></div> <p><a name="nodes-1"><span class="bold_code">nodes(Arg | [Arg]) -> Nodes</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Arg = visible | hidden | connected | this | known</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Nodes = [node()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of nodes according to argument given. The result returned when the argument is a list, is the list of nodes satisfying the disjunction(s) of the list elements.</p> <p><span class="code">Arg</span> can be any of the following:</p> <dl> <dt><strong><span class="code">visible</span></strong></dt> <dd> <p>Nodes connected to this node through normal connections.</p> </dd> <dt><strong><span class="code">hidden</span></strong></dt> <dd> <p>Nodes connected to this node through hidden connections.</p> </dd> <dt><strong><span class="code">connected</span></strong></dt> <dd> <p>All nodes connected to this node.</p> </dd> <dt><strong><span class="code">this</span></strong></dt> <dd> <p>This node.</p> </dd> <dt><strong><span class="code">known</span></strong></dt> <dd> <p>Nodes which are known to this node, i.e., connected, previously connected, etc.</p> </dd> </dl> <p>Some equalities: <span class="code">[node()] = nodes(this)</span>, <span class="code">nodes(connected) = nodes([visible, hidden])</span>, and <span class="code">nodes() = nodes(visible)</span>.</p> <p>If the local node is not alive, <span class="code">nodes(this) == nodes(known) == [nonode@nohost]</span>, for any other <span class="code">Arg</span> the empty list [] is returned.</p> </p></div> <p><a name="now-0"><span class="bold_code">now() -> timestamp()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">timestamp() = {MegaSecs, Secs, MicroSecs}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MegaSecs = Secs = MicroSecs = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the tuple <span class="code">{MegaSecs, Secs, MicroSecs}</span> which is the elapsed time since 00:00 GMT, January 1, 1970 (zero hour) on the assumption that the underlying OS supports this. Otherwise, some other point in time is chosen. It is also guaranteed that subsequent calls to this BIF returns continuously increasing values. Hence, the return value from <span class="code">now()</span> can be used to generate unique time-stamps, and if it is called in a tight loop on a fast machine the time of the node can become skewed.</p> <p>It can only be used to check the local time of day if the time-zone info of the underlying operating system is properly configured.</p> <p>If you do not need the return value to be unique and monotonically increasing, use <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','os.html#timestamp-0');">os:timestamp/0</a></span> instead to avoid some overhead.</p> </p></div> <p><a name="open_port-2"><span class="bold_code">open_port(PortName, PortSettings) -> port()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">PortName = {spawn, Command} | {spawn_driver, Command} | {spawn_executable, FileName} | {fd, In, Out}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Command = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> FileName = [ FileNameChar ] | binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> FileNameChar = integer() (1..255 or any Unicode codepoint, see description)</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> In = Out = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PortSettings = [Opt]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Opt = {packet, N} | stream | {line, L} | {cd, Dir} | {env, Env} | {args, [ ArgString ]} | {arg0, ArgString} | exit_status | use_stdio | nouse_stdio | stderr_to_stdout | in | out | binary | eof</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> N = 1 | 2 | 4</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> L = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Dir = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> ArgString = [ FileNameChar ] | binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Env = [{Name, Val}]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Name = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Val = string() | false</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a port identifier as the result of opening a new Erlang port. A port can be seen as an external Erlang process. <span class="code">PortName</span> is one of the following:</p> <dl> <dt><strong><span class="code">{spawn, Command}</span></strong></dt> <dd> <p>Starts an external program. <span class="code">Command</span> is the name of the external program which will be run. <span class="code">Command</span> runs outside the Erlang work space unless an Erlang driver with the name <span class="code">Command</span> is found. If found, that driver will be started. A driver runs in the Erlang workspace, which means that it is linked with the Erlang runtime system.</p> <p>When starting external programs on Solaris, the system call <span class="code">vfork</span> is used in preference to <span class="code">fork</span> for performance reasons, although it has a history of being less robust. If there are problems with using <span class="code">vfork</span>, setting the environment variable <span class="code">ERL_NO_VFORK</span> to any value will cause <span class="code">fork</span> to be used instead.</p> <p>For external programs, the <span class="code">PATH</span> is searched (or an equivalent method is used to find programs, depending on operating system). This is done by invoking the shell on certain platforms. The first space separated token of the command will be considered as the name of the executable (or driver). This (among other things) makes this option unsuitable for running programs having spaces in file or directory names. Use {spawn_executable, Command} instead if spaces in executable file names is desired.</p> </dd> <dt><strong><span class="code">{spawn_driver, Command}</span></strong></dt> <dd> <p>Works like <span class="code">{spawn, Command}</span>, but demands the first (space separated) token of the command to be the name of a loaded driver. If no driver with that name is loaded, a <span class="code">badarg</span> error is raised.</p> </dd> <dt><strong><span class="code">{spawn_executable, Command}</span></strong></dt> <dd> <p>Works like <span class="code">{spawn, Command}</span>, but only runs external executables. The <span class="code">Command</span> in its whole is used as the name of the executable, including any spaces. If arguments are to be passed, the <span class="code">args</span> and <span class="code">arg0</span> <span class="code">PortSettings</span> can be used.</p> <p>The shell is not usually invoked to start the program, it's executed directly. Neither is the <span class="code">PATH</span> (or equivalent) searched. To find a program in the PATH to execute, use <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','os.html#find_executable-1');">os:find_executable/1</a></span>.</p> <p>Only if a shell script or <span class="code">.bat</span> file is executed, the appropriate command interpreter will implicitly be invoked, but there will still be no command argument expansion or implicit PATH search.</p> <p>The name of the executable as well as the arguments given in <span class="code">args</span> and <span class="code">arg0</span> is subject to Unicode file name translation if the system is running in Unicode file name mode. To avoid translation or force i.e. UTF-8, supply the executable and/or arguments as a binary in the correct encoding. See the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','file.html');">file</a></span> module, the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','file.html#native_name_encoding-0');"> file:native_name_encoding/0</a></span> function and the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','unicode_usage.html');">stdlib users guide </a></span> for details.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p>The characters in the name (if given as a list) can only be > 255 if the Erlang VM is started in Unicode file name translation mode, otherwise the name of the executable is limited to the ISO-latin-1 character set.</p></p></div> </div> <p>If the <span class="code">Command</span> cannot be run, an error exception, with the posix error code as the reason, is raised. The error reason may differ between operating systems. Typically the error <span class="code">enoent</span> is raised when one tries to run a program that is not found and <span class="code">eaccess</span> is raised when the given file is not executable.</p> </dd> <dt><strong><span class="code">{fd, In, Out}</span></strong></dt> <dd> <p>Allows an Erlang process to access any currently opened file descriptors used by Erlang. The file descriptor <span class="code">In</span> can be used for standard input, and the file descriptor <span class="code">Out</span> for standard output. It is only used for various servers in the Erlang operating system (<span class="code">shell</span> and <span class="code">user</span>). Hence, its use is very limited.</p> </dd> </dl> <p><span class="code">PortSettings</span> is a list of settings for the port. Valid settings are:</p> <dl> <dt><strong><span class="code">{packet, N}</span></strong></dt> <dd> <p>Messages are preceded by their length, sent in <span class="code">N</span> bytes, with the most significant byte first. Valid values for <span class="code">N</span> are 1, 2, or 4.</p> </dd> <dt><strong><span class="code">stream</span></strong></dt> <dd> <p>Output messages are sent without packet lengths. A user-defined protocol must be used between the Erlang process and the external object.</p> </dd> <dt><strong><span class="code">{line, L}</span></strong></dt> <dd> <p>Messages are delivered on a per line basis. Each line (delimited by the OS-dependent newline sequence) is delivered in one single message. The message data format is <span class="code">{Flag, Line}</span>, where <span class="code">Flag</span> is either <span class="code">eol</span> or <span class="code">noeol</span> and <span class="code">Line</span> is the actual data delivered (without the newline sequence).</p> <p><span class="code">L</span> specifies the maximum line length in bytes. Lines longer than this will be delivered in more than one message, with the <span class="code">Flag</span> set to <span class="code">noeol</span> for all but the last message. If end of file is encountered anywhere else than immediately following a newline sequence, the last line will also be delivered with the <span class="code">Flag</span> set to <span class="code">noeol</span>. In all other cases, lines are delivered with <span class="code">Flag</span> set to <span class="code">eol</span>.</p> <p>The <span class="code">{packet, N}</span> and <span class="code">{line, L}</span> settings are mutually exclusive.</p> </dd> <dt><strong><span class="code">{cd, Dir}</span></strong></dt> <dd> <p>This is only valid for <span class="code">{spawn, Command}</span> and <span class="code">{spawn_executable, Command}</span>. The external program starts using <span class="code">Dir</span> as its working directory. <span class="code">Dir</span> must be a string. Not available on VxWorks.</p> </dd> <dt><strong><span class="code">{env, Env}</span></strong></dt> <dd> <p>This is only valid for <span class="code">{spawn, Command}</span> and <span class="code">{spawn_executable, Command}</span>. The environment of the started process is extended using the environment specifications in <span class="code">Env</span>.</p> <p><span class="code">Env</span> should be a list of tuples <span class="code">{Name, Val}</span>, where <span class="code">Name</span> is the name of an environment variable, and <span class="code">Val</span> is the value it is to have in the spawned port process. Both <span class="code">Name</span> and <span class="code">Val</span> must be strings. The one exception is <span class="code">Val</span> being the atom <span class="code">false</span> (in analogy with <span class="code">os:getenv/1</span>), which removes the environment variable.</p> <p>If Unicode filename encoding is in effect (see the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#file_name_encoding');">erl manual page</a></span>), the strings (both <span class="code">Name</span> and <span class="code">Value</span>) may contain characters with codepoints > 255.</p> </dd> <dt><strong><span class="code">{args, [ string() ]}</span></strong></dt> <dd> <p>This option is only valid for <span class="code">{spawn_executable, Command}</span> and specifies arguments to the executable. Each argument is given as a separate string and (on Unix) eventually ends up as one element each in the argument vector. On other platforms, similar behavior is mimicked.</p> <p>The arguments are not expanded by the shell prior to being supplied to the executable, most notably this means that file wildcard expansion will not happen. Use <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','filelib.html#wildcard-1');">filelib:wildcard/1</a></span> to expand wildcards for the arguments. Note that even if the program is a Unix shell script, meaning that the shell will ultimately be invoked, wildcard expansion will not happen and the script will be provided with the untouched arguments. On Windows®, wildcard expansion is always up to the program itself, why this isn't an issue.</p> <p>Note also that the actual executable name (a.k.a. <span class="code">argv[0]</span>) should not be given in this list. The proper executable name will automatically be used as argv[0] where applicable.</p> <p>When the Erlang VM is running in Unicode file name mode, the arguments can contain any Unicode characters and will be translated into whatever is appropriate on the underlying OS, which means UTF-8 for all platforms except Windows, which has other (more transparent) ways of dealing with Unicode arguments to programs. To avoid Unicode translation of arguments, they can be supplied as binaries in whatever encoding is deemed appropriate.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p>The characters in the arguments (if given as a list of characters) can only be > 255 if the Erlang VM is started in Unicode file name mode, otherwise the arguments are limited to the ISO-latin-1 character set.</p></p></div> </div> <p>If one, for any reason, wants to explicitly set the program name in the argument vector, the <span class="code">arg0</span> option can be used.</p> </dd> <dt><strong><span class="code">{arg0, string()}</span></strong></dt> <dd> <p>This option is only valid for <span class="code">{spawn_executable, Command}</span> and explicitly specifies the program name argument when running an executable. This might in some circumstances, on some operating systems, be desirable. How the program responds to this is highly system dependent and no specific effect is guaranteed.</p> <p>The unicode file name translation rules of the <span class="code">args</span> option apply to this option as well.</p> </dd> <dt><strong><span class="code">exit_status</span></strong></dt> <dd> <p>This is only valid for <span class="code">{spawn, Command}</span> where <span class="code">Command</span> refers to an external program, and for <span class="code">{spawn_executable, Command}</span>.</p> <p>When the external process connected to the port exits, a message of the form <span class="code">{Port,{exit_status,Status}}</span> is sent to the connected process, where <span class="code">Status</span> is the exit status of the external process. If the program aborts, on Unix the same convention is used as the shells do (i.e., 128+signal).</p> <p>If the <span class="code">eof</span> option has been given as well, the <span class="code">eof</span> message and the <span class="code">exit_status</span> message appear in an unspecified order.</p> <p>If the port program closes its stdout without exiting, the <span class="code">exit_status</span> option will not work.</p> </dd> <dt><strong><span class="code">use_stdio</span></strong></dt> <dd> <p>This is only valid for <span class="code">{spawn, Command}</span> and <span class="code">{spawn_executable, Command}</span>. It allows the standard input and output (file descriptors 0 and 1) of the spawned (UNIX) process for communication with Erlang.</p> </dd> <dt><strong><span class="code">nouse_stdio</span></strong></dt> <dd> <p>The opposite of <span class="code">use_stdio</span>. Uses file descriptors 3 and 4 for communication with Erlang.</p> </dd> <dt><strong><span class="code">stderr_to_stdout</span></strong></dt> <dd> <p>Affects ports to external programs. The executed program gets its standard error file redirected to its standard output file. <span class="code">stderr_to_stdout</span> and <span class="code">nouse_stdio</span> are mutually exclusive.</p> </dd> <dt><strong><span class="code">overlapped_io</span></strong></dt> <dd> <p>Affects ports to external programs on Windows® only. The standard input and standard output handles of the port program will, if this option is supplied, be opened with the flag FILE_FLAG_OVERLAPPED, so that the port program can (and has to) do overlapped I/O on its standard handles. This is not normally the case for simple port programs, but an option of value for the experienced Windows programmer. <strong>On all other platforms, this option is silently discarded</strong>.</p> </dd> <dt><strong><span class="code">in</span></strong></dt> <dd> <p>The port can only be used for input.</p> </dd> <dt><strong><span class="code">out</span></strong></dt> <dd> <p>The port can only be used for output.</p> </dd> <dt><strong><span class="code">binary</span></strong></dt> <dd> <p>All IO from the port are binary data objects as opposed to lists of bytes.</p> </dd> <dt><strong><span class="code">eof</span></strong></dt> <dd> <p>The port will not be closed at the end of the file and produce an exit signal. Instead, it will remain open and a <span class="code">{Port, eof}</span> message will be sent to the process holding the port.</p> </dd> <dt><strong><span class="code">hide</span></strong></dt> <dd> <p>When running on Windows, suppress creation of a new console window when spawning the port program. (This option has no effect on other platforms.)</p> </dd> </dl> <p>The default is <span class="code">stream</span> for all types of port and <span class="code">use_stdio</span> for spawned ports.</p> <p>Failure: If the port cannot be opened, the exit reason is <span class="code">badarg</span>, <span class="code">system_limit</span>, or the Posix error code which most closely describes the error, or <span class="code">einval</span> if no Posix code is appropriate:</p> <dl> <dt><strong><span class="code">badarg</span></strong></dt> <dd> <p>Bad input arguments to <span class="code">open_port</span>.</p> </dd> <dt><strong><span class="code">system_limit</span></strong></dt> <dd> <p>All available ports in the Erlang emulator are in use.</p> </dd> <dt><strong><span class="code">enomem</span></strong></dt> <dd> <p>There was not enough memory to create the port.</p> </dd> <dt><strong><span class="code">eagain</span></strong></dt> <dd> <p>There are no more available operating system processes.</p> </dd> <dt><strong><span class="code">enametoolong</span></strong></dt> <dd> <p>The external command given was too long.</p> </dd> <dt><strong><span class="code">emfile</span></strong></dt> <dd> <p>There are no more available file descriptors (for the operating system process that the Erlang emulator runs in).</p> </dd> <dt><strong><span class="code">enfile</span></strong></dt> <dd> <p>The file table is full (for the entire operating system).</p> </dd> <dt><strong><span class="code">eacces</span></strong></dt> <dd> <p>The <span class="code">Command</span> given in <span class="code">{spawn_executable, Command}</span> does not point out an executable file.</p> </dd> <dt><strong><span class="code">enoent</span></strong></dt> <dd> <p>The <span class="code">Command</span> given in <span class="code">{spawn_executable, Command}</span> does not point out an existing file.</p> </dd> </dl> <p>During use of a port opened using <span class="code">{spawn, Name}</span>, <span class="code">{spawn_driver, Name}</span> or <span class="code">{spawn_executable, Name}</span>, errors arising when sending messages to it are reported to the owning process using signals of the form <span class="code">{'EXIT', Port, PosixCode}</span>. See <span class="code">file(3)</span> for possible values of <span class="code">PosixCode</span>.</p> <p><a name="ERL_MAX_PORTS"></a> The maximum number of ports that can be open at the same time is 1024 by default, but can be configured by the environment variable <span class="code">ERL_MAX_PORTS</span>.</p> </p></div> <p><a name="phash-2"><span class="bold_code">erlang:phash(Term, Range) -> Hash</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Range = 1..2^32</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Hash = 1..Range</span><br> </div> </div> <div class="REFBODY"><p> <p>Portable hash function that will give the same hash for the same Erlang term regardless of machine architecture and ERTS version (the BIF was introduced in ERTS 4.9.1.1). Range can be between 1 and 2^32, the function returns a hash value for <span class="code">Term</span> within the range <span class="code">1..Range</span>.</p> <p>This BIF could be used instead of the old deprecated <span class="code">erlang:hash/2</span> BIF, as it calculates better hashes for all data-types, but consider using <span class="code">phash2/1,2</span> instead.</p> </p></div> <p><a name="phash2-1"><span class="bold_code">erlang:phash2(Term [, Range]) -> Hash</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Range = 1..2^32</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Hash = 0..Range-1</span><br> </div> </div> <div class="REFBODY"><p> <p>Portable hash function that will give the same hash for the same Erlang term regardless of machine architecture and ERTS version (the BIF was introduced in ERTS 5.2). Range can be between 1 and 2^32, the function returns a hash value for <span class="code">Term</span> within the range <span class="code">0..Range-1</span>. When called without the <span class="code">Range</span> argument, a value in the range <span class="code">0..2^27-1</span> is returned.</p> <p>This BIF should always be used for hashing terms. It distributes small integers better than <span class="code">phash/2</span>, and it is faster for bignums and binaries.</p> <p>Note that the range <span class="code">0..Range-1</span> is different from the range of <span class="code">phash/2</span> (<span class="code">1..Range</span>).</p> </p></div> <p><a name="pid_to_list-1"><span class="bold_code">pid_to_list(Pid) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Pid</span>.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.</p> </p></div> </div> </p></div> <p><a name="port_close-1"><span class="bold_code">port_close(Port) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Closes an open port. Roughly the same as <span class="code">Port ! {self(), close}</span> except for the error behaviour (see below), and that the port does <strong>not</strong> reply with <span class="code">{Port, closed}</span>. Any process may close a port with <span class="code">port_close/1</span>, not only the port owner (the connected process).</p> <p>For comparison: <span class="code">Port ! {self(), close}</span> fails with <span class="code">badarg</span> if <span class="code">Port</span> cannot be sent to (i.e., <span class="code">Port</span> refers neither to a port nor to a process). If <span class="code">Port</span> is a closed port nothing happens. If <span class="code">Port</span> is an open port and the calling process is the port owner, the port replies with <span class="code">{Port, closed}</span> when all buffers have been flushed and the port really closes, but if the calling process is not the port owner the <strong>port owner</strong> fails with <span class="code">badsig</span>.</p> <p>Note that any process can close a port using <span class="code">Port ! {PortOwner, close}</span> just as if it itself was the port owner, but the reply always goes to the port owner.</p> <p>In short: <span class="code">port_close(Port)</span> has a cleaner and more logical behaviour than <span class="code">Port ! {self(), close}</span>.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Port</span> is not an open port or the registered name of an open port.</p> </p></div> <p><a name="port_command-2"><span class="bold_code">port_command(Port, Data) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> </div> <div class="REFBODY"><p> <p>Sends data to a port. Same as <span class="code">Port ! {self(), {command, Data}}</span> except for the error behaviour (see below). Any process may send data to a port with <span class="code">port_command/2</span>, not only the port owner (the connected process).</p> <p>For comparison: <span class="code">Port ! {self(), {command, Data}}</span> fails with <span class="code">badarg</span> if <span class="code">Port</span> cannot be sent to (i.e., <span class="code">Port</span> refers neither to a port nor to a process). If <span class="code">Port</span> is a closed port the data message disappears without a sound. If <span class="code">Port</span> is open and the calling process is not the port owner, the <strong>port owner</strong> fails with <span class="code">badsig</span>. The port owner fails with <span class="code">badsig</span> also if <span class="code">Data</span> is not a valid IO list.</p> <p>Note that any process can send to a port using <span class="code">Port ! {PortOwner, {command, Data}}</span> just as if it itself was the port owner.</p> <p>In short: <span class="code">port_command(Port, Data)</span> has a cleaner and more logical behaviour than <span class="code">Port ! {self(), {command, Data}}</span>.</p> <p>If the port is busy, the calling process will be suspended until the port is not busy anymore.</p> <p>Failures:</p> <dl> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Port</span> is not an open port or the registered name of an open port. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Data</span> is not a valid io list. </dd> </dl> </p></div> <p><a name="port_command-3"><span class="bold_code">port_command(Port, Data, OptionList) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = iodata()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">OptionList = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = force</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = nosuspend</span><br> </div> </div> <div class="REFBODY"><p> <p>Sends data to a port. <span class="code">port_command(Port, Data, [])</span> equals <span class="code">port_command(Port, Data)</span>.</p> <p>If the port command is aborted <span class="code">false</span> is returned; otherwise, <span class="code">true</span> is returned.</p> <p>If the port is busy, the calling process will be suspended until the port is not busy anymore.</p> <p>Currently the following <span class="code">Option</span>s are valid:</p> <dl> <dt><strong><span class="code">force</span></strong></dt> <dd>The calling process will not be suspended if the port is busy; instead, the port command is forced through. The call will fail with a <span class="code">notsup</span> exception if the driver of the port does not support this. For more information see the <span class="bold_code"><a href="driver_entry.html#driver_flags">ERL_DRV_FLAG_SOFT_BUSY</a></span> driver flag. </dd> <dt><strong><span class="code">nosuspend</span></strong></dt> <dd>The calling process will not be suspended if the port is busy; instead, the port command is aborted and <span class="code">false</span> is returned. </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>More options may be added in the future.</p> </p></div> </div> <p>Failures:</p> <dl> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Port</span> is not an open port or the registered name of an open port. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Data</span> is not a valid io list. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">OptionList</span> is not a valid option list. </dd> <dt><strong><span class="code">notsup</span></strong></dt> <dd> If the <span class="code">force</span> option has been passed, but the driver of the port does not allow forcing through a busy port. </dd> </dl> </p></div> <p><a name="port_connect-2"><span class="bold_code">port_connect(Port, Pid) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Sets the port owner (the connected port) to <span class="code">Pid</span>. Roughly the same as <span class="code">Port ! {self(), {connect, Pid}}</span> except for the following:</p> <ul> <li> <p>The error behavior differs, see below.</p> </li> <li> <p>The port does <strong>not</strong> reply with <span class="code">{Port,connected}</span>.</p> </li> <li> <p>The new port owner gets linked to the port.</p> </li> </ul> <p>The old port owner stays linked to the port and have to call <span class="code">unlink(Port)</span> if this is not desired. Any process may set the port owner to be any process with <span class="code">port_connect/2</span>.</p> <p>For comparison: <span class="code">Port ! {self(), {connect, Pid}}</span> fails with <span class="code">badarg</span> if <span class="code">Port</span> cannot be sent to (i.e., <span class="code">Port</span> refers neither to a port nor to a process). If <span class="code">Port</span> is a closed port nothing happens. If <span class="code">Port</span> is an open port and the calling process is the port owner, the port replies with <span class="code">{Port, connected}</span> to the old port owner. Note that the old port owner is still linked to the port, and that the new is not. If <span class="code">Port</span> is an open port and the calling process is not the port owner, the <strong>port owner</strong> fails with <span class="code">badsig</span>. The port owner fails with <span class="code">badsig</span> also if <span class="code">Pid</span> is not an existing local pid.</p> <p>Note that any process can set the port owner using <span class="code">Port ! {PortOwner, {connect, Pid}}</span> just as if it itself was the port owner, but the reply always goes to the port owner.</p> <p>In short: <span class="code">port_connect(Port, Pid)</span> has a cleaner and more logical behaviour than <span class="code">Port ! {self(),{connect,Pid}}</span>.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Port</span> is not an open port or the registered name of an open port, or if <span class="code">Pid</span> is not an existing local pid.</p> </p></div> <p><a name="port_control-3"><span class="bold_code">port_control(Port, Operation, Data) -> Res</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Operation = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = Res = iodata()</span><br> </div> </div> <div class="REFBODY"><p> <p>Performs a synchronous control operation on a port. The meaning of <span class="code">Operation</span> and <span class="code">Data</span> depends on the port, i.e., on the port driver. Not all port drivers support this control feature.</p> <p>Returns: a list of integers in the range 0 through 255, or a binary, depending on the port driver. The meaning of the returned data also depends on the port driver.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Port</span> is not an open port or the registered name of an open port, if <span class="code">Operation</span> cannot fit in a 32-bit integer, if the port driver does not support synchronous control operations, or if the port driver so decides for any reason (probably something wrong with <span class="code">Operation</span> or <span class="code">Data</span>).</p> </p></div> <p><a name="port_call-3"><span class="bold_code">erlang:port_call(Port, Operation, Data) -> term()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Operation = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Performs a synchronous call to a port. The meaning of <span class="code">Operation</span> and <span class="code">Data</span> depends on the port, i.e., on the port driver. Not all port drivers support this feature.</p> <p><span class="code">Port</span> is a port identifier, referring to a driver.</p> <p><span class="code">Operation</span> is an integer, which is passed on to the driver.</p> <p><span class="code">Data</span> is any Erlang term. This data is converted to binary term format and sent to the port.</p> <p>Returns: a term from the driver. The meaning of the returned data also depends on the port driver.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Port</span> is not an open port or the registered name of an open port, if <span class="code">Operation</span> cannot fit in a 32-bit integer, if the port driver does not support synchronous control operations, or if the port driver so decides for any reason (probably something wrong with <span class="code">Operation</span> or <span class="code">Data</span>).</p> </p></div> <p><a name="port_info-1"><span class="bold_code">erlang:port_info(Port) -> [{Item, Info}] | undefined</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item, Info -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list containing tuples with information about the <span class="code">Port</span>, or <span class="code">undefined</span> if the port is not open. The order of the tuples is not defined, nor are all the tuples mandatory.</p> <dl> <dt><strong><span class="code">{registered_name, RegName}</span></strong></dt> <dd> <p><span class="code">RegName</span> (an atom) is the registered name of the port. If the port has no registered name, this tuple is not present in the list.</p> </dd> <dt><strong><span class="code">{id, Index}</span></strong></dt> <dd> <p><span class="code">Index</span> (an integer) is the internal index of the port. This index may be used to separate ports.</p> </dd> <dt><strong><span class="code">{connected, Pid}</span></strong></dt> <dd> <p><span class="code">Pid</span> is the process connected to the port.</p> </dd> <dt><strong><span class="code">{links, Pids}</span></strong></dt> <dd> <p><span class="code">Pids</span> is a list of pids to which processes the port is linked.</p> </dd> <dt><strong><span class="code">{name, String}</span></strong></dt> <dd> <p><span class="code">String</span> is the command name set by <span class="code">open_port</span>.</p> </dd> <dt><strong><span class="code">{input, Bytes}</span></strong></dt> <dd> <p><span class="code">Bytes</span> is the total number of bytes read from the port.</p> </dd> <dt><strong><span class="code">{output, Bytes}</span></strong></dt> <dd> <p><span class="code">Bytes</span> is the total number of bytes written to the port.</p> </dd> <dt><strong><span class="code">{os_pid, Integer | undefined}</span></strong></dt> <dd> <p><span class="code">Integer</span> is the process identifier (or equivalent) of an OS process created with <span class="code">open_port({spawn | spawn_executable, Command}, Options)</span>. If the port is not the result of spawning an OS process, the value is <span class="code">undefined</span>.</p> </dd> </dl> <p>Failure: <span class="code">badarg</span> if <span class="code">Port</span> is not a local port.</p> </p></div> <p><a name="port_info-2"><span class="bold_code">erlang:port_info(Port, Item) -> {Item, Info} | undefined | []</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port() | atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item, Info -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns information about <span class="code">Port</span> as specified by <span class="code">Item</span>, or <span class="code">undefined</span> if the port is not open. Also, if <span class="code">Item == registered_name</span> and the port has no registered name, [] is returned.</p> <p>For valid values of <span class="code">Item</span>, and corresponding values of <span class="code">Info</span>, see <span class="bold_code"><a href="#port_info-1">erlang:port_info/1</a></span>.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Port</span> is not a local port.</p> </p></div> <p><a name="port_to_list-1"><span class="bold_code">erlang:port_to_list(Port) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Port = port()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of the port identifier <span class="code">Port</span>.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.</p> </p></div> </div> </p></div> <p><a name="ports-0"><span class="bold_code">erlang:ports() -> [port()]</span></a><br></p> <div class="REFBODY"><p> <p>Returns a list of all ports on the local node.</p> </p></div> <p><a name="pre_loaded-0"><span class="bold_code">pre_loaded() -> [Module]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of Erlang modules which are pre-loaded in the system. As all loading of code is done through the file system, the file system must have been loaded previously. Hence, at least the module <span class="code">init</span> must be pre-loaded.</p> </p></div> <p><a name="process_display-2"><span class="bold_code">erlang:process_display(Pid, Type) -> void()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Type = backtrace</span><br> </div> </div> <div class="REFBODY"><p> <p>Writes information about the local process <span class="code">Pid</span> on standard error. The currently allowed value for the atom <span class="code">Type</span> is <span class="code">backtrace</span>, which shows the contents of the call stack, including information about the call chain, with the current function printed first. The format of the output is not further defined.</p> </p></div> <p><a name="process_flag-2"><span class="bold_code">process_flag(Flag, Value) -> OldValue</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Flag, Value, OldValue -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Sets certain flags for the process which calls this function. Returns the old value of the flag.</p> <dl> <dt><strong><span class="code">process_flag(trap_exit, Boolean)</span></strong></dt> <dd> <p>When <span class="code">trap_exit</span> is set to <span class="code">true</span>, exit signals arriving to a process are converted to <span class="code">{'EXIT', From, Reason}</span> messages, which can be received as ordinary messages. If <span class="code">trap_exit</span> is set to <span class="code">false</span>, the process exits if it receives an exit signal other than <span class="code">normal</span> and the exit signal is propagated to its linked processes. Application processes should normally not trap exits.</p> <p>See also <span class="bold_code"><a href="#exit-2">exit/2</a></span>.</p> </dd> <dt><strong><span class="code">process_flag(error_handler, Module)</span></strong></dt> <dd> <p>This is used by a process to redefine the error handler for undefined function calls and undefined registered processes. Inexperienced users should not use this flag since code auto-loading is dependent on the correct operation of the error handling module.</p> </dd> <dt><strong><span class="code">process_flag(min_heap_size, MinHeapSize)</span></strong></dt> <dd> <p>This changes the minimum heap size for the calling process.</p> </dd> <dt><strong><span class="code">process_flag(min_bin_vheap_size, MinBinVHeapSize)</span></strong></dt> <dd> <p>This changes the minimum binary virtual heap size for the calling process.</p> </dd> <dt><strong><a name="process_flag_priority"><span class="code">process_flag(priority, Level)</span></a></strong></dt> <dd> <p>This sets the process priority. <span class="code">Level</span> is an atom. There are currently four priority levels: <span class="code">low</span>, <span class="code">normal</span>, <span class="code">high</span>, and <span class="code">max</span>. The default priority level is <span class="code">normal</span>. <strong>NOTE</strong>: The <span class="code">max</span> priority level is reserved for internal use in the Erlang runtime system, and should <strong>not</strong> be used by others. </p> <p>Internally in each priority level processes are scheduled in a round robin fashion. </p> <p>Execution of processes on priority <span class="code">normal</span> and priority <span class="code">low</span> will be interleaved. Processes on priority <span class="code">low</span> will be selected for execution less frequently than processes on priority <span class="code">normal</span>. </p> <p>When there are runnable processes on priority <span class="code">high</span> no processes on priority <span class="code">low</span>, or <span class="code">normal</span> will be selected for execution. Note, however, that this does <strong>not</strong> mean that no processes on priority <span class="code">low</span>, or <span class="code">normal</span> will be able to run when there are processes on priority <span class="code">high</span> running. On the runtime system with SMP support there might be more processes running in parallel than processes on priority <span class="code">high</span>, i.e., a <span class="code">low</span>, and a <span class="code">high</span> priority process might execute at the same time. </p> <p>When there are runnable processes on priority <span class="code">max</span> no processes on priority <span class="code">low</span>, <span class="code">normal</span>, or <span class="code">high</span> will be selected for execution. As with the <span class="code">high</span> priority, processes on lower priorities might execute in parallel with processes on priority <span class="code">max</span>. </p> <p>Scheduling is preemptive. Regardless of priority, a process is preempted when it has consumed more than a certain amount of reductions since the last time it was selected for execution. </p> <p><strong>NOTE</strong>: You should not depend on the scheduling to remain exactly as it is today. Scheduling, at least on the runtime system with SMP support, is very likely to be modified in the future in order to better utilize available processor cores. </p> <p>There is currently <strong>no</strong> automatic mechanism for avoiding priority inversion, such as priority inheritance, or priority ceilings. When using priorities you have to take this into account and handle such scenarios by yourself. </p> <p>Making calls from a <span class="code">high</span> priority process into code that you don't have control over may cause the <span class="code">high</span> priority process to wait for a processes with lower priority, i.e., effectively decreasing the priority of the <span class="code">high</span> priority process during the call. Even if this isn't the case with one version of the code that you don't have under your control, it might be the case in a future version of it. This might, for example, happen if a <span class="code">high</span> priority process triggers code loading, since the code server runs on priority <span class="code">normal</span>. </p> <p>Other priorities than <span class="code">normal</span> are normally not needed. When other priorities are used, they need to be used with care, especially the <span class="code">high</span> priority <strong>must</strong> be used with care. A process on <span class="code">high</span> priority should only perform work for short periods of time. Busy looping for long periods of time in a <span class="code">high</span> priority process will most likely cause problems, since there are important servers in OTP running on priority <span class="code">normal</span>. </p> </dd> <dt><strong><span class="code">process_flag(save_calls, N)</span></strong></dt> <dd> <p><span class="code">N</span> must be an integer in the interval 0..10000. If <span class="code">N</span> > 0, call saving is made active for the process, which means that information about the <span class="code">N</span> most recent global function calls, BIF calls, sends and receives made by the process are saved in a list, which can be retrieved with <span class="code">process_info(Pid, last_calls)</span>. A global function call is one in which the module of the function is explicitly mentioned. Only a fixed amount of information is saved: a tuple <span class="code">{Module, Function, Arity}</span> for function calls, and the mere atoms <span class="code">send</span>, <span class="code">'receive'</span> and <span class="code">timeout</span> for sends and receives (<span class="code">'receive'</span> when a message is received and <span class="code">timeout</span> when a receive times out). If <span class="code">N</span> = 0, call saving is disabled for the process, which is the default. Whenever the size of the call saving list is set, its contents are reset.</p> </dd> <dt><strong><span class="code">process_flag(sensitive, Boolean)</span></strong></dt> <dd> <p>Set or clear the <span class="code">sensitive</span> flag for the current process. When a process has been marked as sensitive by calling <span class="code">process_flag(sensitive, true)</span>, features in the run-time system that can be used for examining the data and/or inner working of the process are silently disabled.</p> <p>Features that are disabled include (but are not limited to) the following:</p> <p>Tracing: Trace flags can still be set for the process, but no trace messages of any kind will be generated. (If the <span class="code">sensitive</span> flag is turned off, trace messages will again be generated if there are any trace flags set.)</p> <p>Sequential tracing: The sequential trace token will be propagated as usual, but no sequential trace messages will be generated.</p> <p><span class="code">process_info/1,2</span> cannot be used to read out the message queue or the process dictionary (both will be returned as empty lists).</p> <p>Stack back-traces cannot be displayed for the process.</p> <p>In crash dumps, the stack, messages, and the process dictionary will be omitted.</p> <p>If <span class="code">{save_calls,N}</span> has been set for the process, no function calls will be saved to the call saving list. (The call saving list will not be cleared; furthermore, send, receive, and timeout events will still be added to the list.)</p> </dd> </dl> </p></div> <p><a name="process_flag-3"><span class="bold_code">process_flag(Pid, Flag, Value) -> OldValue</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Flag, Value, OldValue -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Sets certain flags for the process <span class="code">Pid</span>, in the same manner as <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>. Returns the old value of the flag. The allowed values for <span class="code">Flag</span> are only a subset of those allowed in <span class="code">process_flag/2</span>, namely: <span class="code">save_calls</span>.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Pid</span> is not a local process.</p> </p></div> <p><a name="process_info-1"><span class="bold_code">process_info(Pid) -> InfoResult</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Info = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoTuple = {Item, Info}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoTupleList = [InfoTuple]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoResult = InfoTupleList | undefined</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list containing <span class="code">InfoTuple</span>s with miscellaneous information about the process identified by <span class="code">Pid</span>, or <span class="code">undefined</span> if the process is not alive. </p> <p> The order of the <span class="code">InfoTuple</span>s is not defined, nor are all the <span class="code">InfoTuple</span>s mandatory. The <span class="code">InfoTuple</span>s part of the result may be changed without prior notice. Currently <span class="code">InfoTuple</span>s with the following <span class="code">Item</span>s are part of the result: <span class="code">current_function</span>, <span class="code">initial_call</span>, <span class="code">status</span>, <span class="code">message_queue_len</span>, <span class="code">messages</span>, <span class="code">links</span>, <span class="code">dictionary</span>, <span class="code">trap_exit</span>, <span class="code">error_handler</span>, <span class="code">priority</span>, <span class="code">group_leader</span>, <span class="code">total_heap_size</span>, <span class="code">heap_size</span>, <span class="code">stack_size</span>, <span class="code">reductions</span>, and <span class="code">garbage_collection</span>. If the process identified by <span class="code">Pid</span> has a registered name also an <span class="code">InfoTuple</span> with <span class="code">Item == registered_name</span> will appear. </p> <p>See <span class="bold_code"><a href="#process_info-2">process_info/2</a></span> for information about specific <span class="code">InfoTuple</span>s.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for <strong>debugging only</strong>, use <span class="bold_code"><a href="#process_info-2">process_info/2</a></span> for all other purposes. </p> </p></div> </div> <p>Failure: <span class="code">badarg</span> if <span class="code">Pid</span> is not a local process.</p> </p></div> <p><a name="process_info-2"><span class="bold_code">process_info(Pid, ItemSpec) -> InfoResult</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Info = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">ItemList = [Item]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">ItemSpec = Item | ItemList</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoTuple = {Item, Info}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoTupleList = [InfoTuple]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoResult = InfoTuple | InfoTupleList | undefined | []</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns information about the process identified by <span class="code">Pid</span> as specified by the <span class="code">ItemSpec</span>, or <span class="code">undefined</span> if the process is not alive. </p> <p>If the process is alive and <span class="code">ItemSpec</span> is a single <span class="code">Item</span>, the returned value is the corresponding <span class="code">InfoTuple</span> unless <span class="code">ItemSpec == registered_name</span> and the process has no registered name. In this case <span class="code">[]</span> is returned. This strange behavior is due to historical reasons, and is kept for backward compatibility. </p> <p>If <span class="code">ItemSpec</span> is an <span class="code">ItemList</span>, the result is an <span class="code">InfoTupleList</span>. The <span class="code">InfoTuple</span>s in the <span class="code">InfoTupleList</span> will appear with the corresponding <span class="code">Item</span>s in the same order as the <span class="code">Item</span>s appeared in the <span class="code">ItemList</span>. Valid <span class="code">Item</span>s may appear multiple times in the <span class="code">ItemList</span>. </p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p>If <span class="code">registered_name</span> is part of an <span class="code">ItemList</span> and the process has no name registered a <span class="code">{registered_name, []}</span> <span class="code">InfoTuple</span> <strong>will</strong> appear in the resulting <span class="code">InfoTupleList</span>. This behavior is different than when <span class="code">ItemSpec == registered_name</span>, and than when <span class="code">process_info/1</span> is used. </p></p></div> </div> <p>Currently the following <span class="code">InfoTuple</span>s with corresponding <span class="code">Item</span>s are valid:</p> <dl> <dt><strong><span class="code">{backtrace, Bin}</span></strong></dt> <dd> <p>The binary <span class="code">Bin</span> contains the same information as the output from <span class="code">erlang:process_display(Pid, backtrace)</span>. Use <span class="code">binary_to_list/1</span> to obtain the string of characters from the binary.</p> </dd> <dt><strong><span class="code">{binary, BinInfo}</span></strong></dt> <dd> <p><span class="code">BinInfo</span> is a list containing miscellaneous information about binaries currently being referred to by this process. This <span class="code">InfoTuple</span> may be changed or removed without prior notice.</p> </dd> <dt><strong><span class="code">{catchlevel, CatchLevel}</span></strong></dt> <dd> <p><span class="code">CatchLevel</span> is the number of currently active catches in this process. This <span class="code">InfoTuple</span> may be changed or removed without prior notice.</p> </dd> <dt><strong><span class="code">{current_function, {Module, Function, Arity}}</span></strong></dt> <dd> <p><span class="code">Module</span>, <span class="code">Function</span>, <span class="code">Arity</span> is the current function call of the process.</p> </dd> <dt><strong><span class="code">{current_location, {Module, Function, Arity, Location}}</span></strong></dt> <dd> <p><span class="code">Module</span>, <span class="code">Function</span>, <span class="code">Arity</span> is the current function call of the process. <span class="code">Location</span> is a list of two-tuples that describes the location in the source code. </p> </dd> <dt><strong><span class="code">{current_stacktrace, Stack}</span></strong></dt> <dd> <p>Return the current call stack back-trace (<strong>stacktrace</strong>) of the process. The stack has the same format as returned by <span class="bold_code"><a href="#get_stacktrace-0">erlang:get_stacktrace/0</a></span>. </p> </dd> <dt><strong><span class="code">{dictionary, Dictionary}</span></strong></dt> <dd> <p><span class="code">Dictionary</span> is the dictionary of the process.</p> </dd> <dt><strong><span class="code">{error_handler, Module}</span></strong></dt> <dd> <p><span class="code">Module</span> is the error handler module used by the process (for undefined function calls, for example).</p> </dd> <dt><strong><span class="code">{garbage_collection, GCInfo}</span></strong></dt> <dd> <p><span class="code">GCInfo</span> is a list which contains miscellaneous information about garbage collection for this process. The content of <span class="code">GCInfo</span> may be changed without prior notice.</p> </dd> <dt><strong><span class="code">{group_leader, GroupLeader}</span></strong></dt> <dd> <p><span class="code">GroupLeader</span> is group leader for the IO of the process.</p> </dd> <dt><strong><span class="code">{heap_size, Size}</span></strong></dt> <dd> <p><span class="code">Size</span> is the size in words of youngest heap generation of the process. This generation currently include the stack of the process. This information is highly implementation dependent, and may change if the implementation change. </p> </dd> <dt><strong><span class="code">{initial_call, {Module, Function, Arity}}</span></strong></dt> <dd> <p><span class="code">Module</span>, <span class="code">Function</span>, <span class="code">Arity</span> is the initial function call with which the process was spawned.</p> </dd> <dt><strong><span class="code">{links, PidsAndPorts}</span></strong></dt> <dd> <p><span class="code">PidsAndPorts</span> is a list of pids and port identifiers, with processes or ports to which the process has a link.</p> </dd> <dt><strong><span class="code">{last_calls, false|Calls}</span></strong></dt> <dd> <p>The value is <span class="code">false</span> if call saving is not active for the process (see <span class="bold_code"><a href="#process_flag-3">process_flag/3</a></span>). If call saving is active, a list is returned, in which the last element is the most recent called.</p> </dd> <dt><strong><span class="code">{memory, Size}</span></strong></dt> <dd> <p><span class="code">Size</span> is the size in bytes of the process. This includes call stack, heap and internal structures.</p> </dd> <dt><strong><span class="code">{message_queue_len, MessageQueueLen}</span></strong></dt> <dd> <p><span class="code">MessageQueueLen</span> is the number of messages currently in the message queue of the process. This is the length of the list <span class="code">MessageQueue</span> returned as the info item <span class="code">messages</span> (see below).</p> </dd> <dt><strong><span class="code">{messages, MessageQueue}</span></strong></dt> <dd> <p><span class="code">MessageQueue</span> is a list of the messages to the process, which have not yet been processed.</p> </dd> <dt><strong><span class="code">{min_heap_size, MinHeapSize}</span></strong></dt> <dd> <p><span class="code">MinHeapSize</span> is the minimum heap size for the process.</p> </dd> <dt><strong><span class="code">{min_bin_vheap_size, MinBinVHeapSize}</span></strong></dt> <dd> <p><span class="code">MinBinVHeapSize</span> is the minimum binary virtual heap size for the process.</p> </dd> <dt><strong><span class="code">{monitored_by, Pids}</span></strong></dt> <dd> <p>A list of pids that are monitoring the process (with <span class="code">monitor/2</span>).</p> </dd> <dt><strong><span class="code">{monitors, Monitors}</span></strong></dt> <dd> <p>A list of monitors (started by <span class="code">monitor/2</span>) that are active for the process. For a local process monitor or a remote process monitor by pid, the list item is <span class="code">{process, Pid}</span>, and for a remote process monitor by name, the list item is <span class="code">{process, {RegName, Node}}</span>.</p> </dd> <dt><strong><span class="code">{priority, Level}</span></strong></dt> <dd> <p><span class="code">Level</span> is the current priority level for the process. For more information on priorities see <span class="bold_code"><a href="#process_flag_priority">process_flag(priority, Level)</a></span>.</p> </dd> <dt><strong><span class="code">{reductions, Number}</span></strong></dt> <dd> <p><span class="code">Number</span> is the number of reductions executed by the process.</p> </dd> <dt><strong><span class="code">{registered_name, Atom}</span></strong></dt> <dd> <p><span class="code">Atom</span> is the registered name of the process. If the process has no registered name, this tuple is not present in the list.</p> </dd> <dt><strong><span class="code">{sequential_trace_token, [] | SequentialTraceToken}</span></strong></dt> <dd> <p><span class="code">SequentialTraceToken</span> the sequential trace token for the process. This <span class="code">InfoTuple</span> may be changed or removed without prior notice.</p> </dd> <dt><strong><span class="code">{stack_size, Size}</span></strong></dt> <dd> <p><span class="code">Size</span> is the stack size of the process in words.</p> </dd> <dt><strong><span class="code">{status, Status}</span></strong></dt> <dd> <p><span class="code">Status</span> is the status of the process. <span class="code">Status</span> is <span class="code">exiting</span>, <span class="code">garbage_collecting</span>, <span class="code">waiting</span> (for a message), <span class="code">running</span>, <span class="code">runnable</span> (ready to run, but another process is running), or <span class="code">suspended</span> (suspended on a "busy" port or by the <span class="code">erlang:suspend_process/[1,2]</span> BIF).</p> </dd> <dt><strong><span class="code">{suspending, SuspendeeList}</span></strong></dt> <dd> <p><span class="code">SuspendeeList</span> is a list of <span class="code">{Suspendee, ActiveSuspendCount, OutstandingSuspendCount}</span> tuples. <span class="code">Suspendee</span> is the pid of a process that have been or is to be suspended by the process identified by <span class="code">Pid</span> via the <span class="bold_code"><a href="#suspend_process-2">erlang:suspend_process/2</a></span> BIF, or the <span class="bold_code"><a href="#suspend_process-1">erlang:suspend_process/1</a></span> BIF. <span class="code">ActiveSuspendCount</span> is the number of times the <span class="code">Suspendee</span> has been suspended by <span class="code">Pid</span>. <span class="code">OutstandingSuspendCount</span> is the number of not yet completed suspend requests sent by <span class="code">Pid</span>. That is, if <span class="code">ActiveSuspendCount /= 0</span>, <span class="code">Suspendee</span> is currently in the suspended state, and if <span class="code">OutstandingSuspendCount /= 0</span> the <span class="code">asynchronous</span> option of <span class="code">erlang:suspend_process/2</span> has been used and the suspendee has not yet been suspended by <span class="code">Pid</span>. Note that the <span class="code">ActiveSuspendCount</span> and <span class="code">OutstandingSuspendCount</span> are not the total suspend count on <span class="code">Suspendee</span>, only the parts contributed by <span class="code">Pid</span>. </p> </dd> <dt><strong><span class="code">{total_heap_size, Size}</span></strong></dt> <dd> <p><span class="code">Size</span> is the total size in words of all heap fragments of the process. This currently include the stack of the process. </p> </dd> <dt><strong><span class="code">{trace, InternalTraceFlags}</span></strong></dt> <dd> <p><span class="code">InternalTraceFlags</span> is an integer representing internal trace flag for this process. This <span class="code">InfoTuple</span> may be changed or removed without prior notice.</p> </dd> <dt><strong><span class="code">{trap_exit, Boolean}</span></strong></dt> <dd> <p><span class="code">Boolean</span> is <span class="code">true</span> if the process is trapping exits, otherwise it is <span class="code">false</span>.</p> </dd> </dl> <p>Note however, that not all implementations support every one of the above <span class="code">Items</span>.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Pid</span> is not a local process, or if <span class="code">Item</span> is not a valid <span class="code">Item</span>.</p> </p></div> <p><a name="processes-0"><span class="bold_code">processes() -> [pid()]</span></a><br></p> <div class="REFBODY"><p> <p>Returns a list of process identifiers corresponding to all the processes currently existing on the local node. </p> <p>Note that a process that is exiting, exists but is not alive, i.e., <span class="code">is_process_alive/1</span> will return <span class="code">false</span> for a process that is exiting, but its process identifier will be part of the result returned from <span class="code">processes/0</span>. </p> <div class="example"><pre> > <span class="bold_code">processes().</span> [<0.0.0>,<0.2.0>,<0.4.0>,<0.5.0>,<0.7.0>,<0.8.0>]</pre></div> </p></div> <p><a name="purge_module-1"><span class="bold_code">purge_module(Module) -> void()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Removes old code for <span class="code">Module</span>. Before this BIF is used, <span class="code">erlang:check_process_code/2</span> should be called to check that no processes are executing old code in the module.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for the code server (see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','kernel','code.html');">code(3)</a></span>) and should not be used elsewhere.</p> </p></div> </div> <p>Failure: <span class="code">badarg</span> if there is no old code for <span class="code">Module</span>.</p> </p></div> <p><a name="put-2"><span class="bold_code">put(Key, Val) -> OldVal | undefined</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Key = Val = OldVal = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Adds a new <span class="code">Key</span> to the process dictionary, associated with the value <span class="code">Val</span>, and returns <span class="code">undefined</span>. If <span class="code">Key</span> already exists, the old value is deleted and replaced by <span class="code">Val</span> and the function returns the old value.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The values stored when <span class="code">put</span> is evaluated within the scope of a <span class="code">catch</span> will not be retracted if a <span class="code">throw</span> is evaluated, or if an error occurs.</p> </p></div> </div> <div class="example"><pre> > <span class="bold_code">X = put(name, walrus), Y = put(name, carpenter),</span> <span class="bold_code">Z = get(name),</span> <span class="bold_code">{X, Y, Z}.</span> {undefined,walrus,carpenter}</pre></div> </p></div> <p><a name="raise-3"><span class="bold_code">erlang:raise(Class, Reason, Stacktrace)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Class = error | exit | throw</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Reason = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Stacktrace = [{Module, Function, Arity | Args} | {Fun, Args}]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Arity = arity()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Args = [term()]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Fun = [fun()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Stops the execution of the calling process with an exception of given class, reason and call stack backtrace (<strong>stacktrace</strong>).</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging and for use in the Erlang operating system. In general, it should be avoided in applications, unless you know very well what you are doing.</p> </p></div> </div> <p><span class="code">Class</span> is one of <span class="code">error</span>, <span class="code">exit</span> or <span class="code">throw</span>, so if it were not for the stacktrace <span class="code">erlang:raise(Class, Reason, Stacktrace)</span> is equivalent to <span class="code">erlang:Class(Reason)</span>. <span class="code">Reason</span> is any term and <span class="code">Stacktrace</span> is a list as returned from <span class="code">get_stacktrace()</span>, that is a list of 4-tuples <span class="code">{Module, Function, Arity | Args, Location}</span> where <span class="code">Module</span> and <span class="code">Function</span> are atoms and the third element is an integer arity or an argument list. The stacktrace may also contain <span class="code">{Fun, Args, Location}</span> tuples where <span class="code">Fun</span> is a local fun and <span class="code">Args</span> is an argument list.</p> <p>The <span class="code">Location</span> element at the end is optional. Omitting it is equivalent to specifying an empty list.</p> <p>The stacktrace is used as the exception stacktrace for the calling process; it will be truncated to the current maximum stacktrace depth.</p> <p>Because evaluating this function causes the process to terminate, it has no return value - unless the arguments are invalid, in which case the function <strong>returns the error reason</strong>, that is <span class="code">badarg</span>. If you want to be really sure not to return you can call <span class="code">error(erlang:raise(Class, Reason, Stacktrace))</span> and hope to distinguish exceptions later.</p> </p></div> <p><a name="read_timer-1"><span class="bold_code">erlang:read_timer(TimerRef) -> integer() >= 0 | false</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">TimerRef = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p><span class="code">TimerRef</span> is a timer reference returned by <span class="bold_code"><a href="#send_after-3">erlang:send_after/3</a></span> or <span class="bold_code"><a href="#start_timer-3">erlang:start_timer/3</a></span>. If the timer is active, the function returns the time in milliseconds left until the timer will expire, otherwise <span class="code">false</span> (which means that <span class="code">TimerRef</span> was never a timer, that it has been cancelled, or that it has already delivered its message).</p> <p>See also <span class="bold_code"><a href="#send_after-3">erlang:send_after/3</a></span>, <span class="bold_code"><a href="#start_timer-3">erlang:start_timer/3</a></span>, and <span class="bold_code"><a href="#cancel_timer-1">erlang:cancel_timer/1</a></span>.</p> </p></div> <p><a name="ref_to_list-1"><span class="bold_code">erlang:ref_to_list(Ref) -> string()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Ref = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a string which corresponds to the text representation of <span class="code">Ref</span>.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.</p> </p></div> </div> </p></div> <p><a name="register-2"><span class="bold_code">register(RegName, Pid | Port) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">RegName = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Pid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Port = port()</span><br> </div> </div> <div class="REFBODY"><p> <p>Associates the name <span class="code">RegName</span> with a pid or a port identifier. <span class="code">RegName</span>, which must be an atom, can be used instead of the pid / port identifier in the send operator (<span class="code">RegName ! Message</span>).</p> <div class="example"><pre> > <span class="bold_code">register(db, Pid).</span> true</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">Pid</span> is not an existing, local process or port, if <span class="code">RegName</span> is already in use, if the process or port is already registered (already has a name), or if <span class="code">RegName</span> is the atom <span class="code">undefined</span>.</p> </p></div> <p><a name="registered-0"><span class="bold_code">registered() -> [RegName]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">RegName = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of names which have been registered using <span class="bold_code"><a href="#register-2">register/2</a></span>.</p> <div class="example"><pre> > <span class="bold_code">registered().</span> [code_server, file_server, init, user, my_db]</pre></div> </p></div> <p><a name="resume_process-1"><span class="bold_code">erlang:resume_process(Suspendee) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Suspendee = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Decreases the suspend count on the process identified by <span class="code">Suspendee</span>. <span class="code">Suspendee</span> should previously have been suspended via <span class="bold_code"><a href="#suspend_process-2">erlang:suspend_process/2</a></span>, or <span class="bold_code"><a href="#suspend_process-1">erlang:suspend_process/1</a></span> by the process calling <span class="code">erlang:resume_process(Suspendee)</span>. When the suspend count on <span class="code">Suspendee</span> reach zero, <span class="code">Suspendee</span> will be resumed, i.e., the state of the <span class="code">Suspendee</span> is changed from suspended into the state <span class="code">Suspendee</span> was in before it was suspended. </p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging only.</p> </p></div> </div> <p>Failures:</p> <dl> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Suspendee</span> isn't a process identifier. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If the process calling <span class="code">erlang:resume_process/1</span> had not previously increased the suspend count on the process identified by <span class="code">Suspendee</span>. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If the process identified by <span class="code">Suspendee</span> is not alive. </dd> </dl> </p></div> <p><a name="round-1"><span class="bold_code">round(Number) -> integer()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Number = number()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer by rounding <span class="code">Number</span>.</p> <div class="example"><pre> > <span class="bold_code">round(5.5).</span> 6</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="self-0"><span class="bold_code">self() -> pid()</span></a><br></p> <div class="REFBODY"><p> <p>Returns the pid (process identifier) of the calling process.</p> <div class="example"><pre> > <span class="bold_code">self().</span> <0.26.0></pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="send-2"><span class="bold_code">erlang:send(Dest, Msg) -> Msg</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Dest = pid() | port() | RegName | {RegName, Node}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Msg = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> RegName = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Node = node()</span><br> </div> </div> <div class="REFBODY"><p> <p>Sends a message and returns <span class="code">Msg</span>. This is the same as <span class="code">Dest ! Msg</span>.</p> <p><span class="code">Dest</span> may be a remote or local pid, a (local) port, a locally registered name, or a tuple <span class="code">{RegName, Node}</span> for a registered name at another node.</p> </p></div> <p><a name="send-3"><span class="bold_code">erlang:send(Dest, Msg, [Option]) -> Res</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Dest = pid() | port() | RegName | {RegName, Node}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> RegName = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Node = node()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Msg = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = nosuspend | noconnect</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Res = ok | nosuspend | noconnect</span><br> </div> </div> <div class="REFBODY"><p> <p>Sends a message and returns <span class="code">ok</span>, or does not send the message but returns something else (see below). Otherwise the same as <span class="bold_code"><a href="#send-2">erlang:send/2</a></span>. See also <span class="bold_code"><a href="#send_nosuspend-2">erlang:send_nosuspend/2,3</a></span>. for more detailed explanation and warnings.</p> <p>The possible options are:</p> <dl> <dt><strong><span class="code">nosuspend</span></strong></dt> <dd> <p>If the sender would have to be suspended to do the send, <span class="code">nosuspend</span> is returned instead.</p> </dd> <dt><strong><span class="code">noconnect</span></strong></dt> <dd> <p>If the destination node would have to be auto-connected before doing the send, <span class="code">noconnect</span> is returned instead.</p> </dd> </dl> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>As with <span class="code">erlang:send_nosuspend/2,3</span>: Use with extreme care!</p> </p></div> </div> </p></div> <p><a name="send_after-3"><span class="bold_code">erlang:send_after(Time, Dest, Msg) -> TimerRef</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Time = integer() >= 0</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> 0 <= Time <= 4294967295</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Dest = pid() | RegName </span><br> </div> <div class="REFTYPES"> <span class="bold_code"> LocalPid = pid() (of a process, alive or dead, on the local node)</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Msg = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TimerRef = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p>Starts a timer which will send the message <span class="code">Msg</span> to <span class="code">Dest</span> after <span class="code">Time</span> milliseconds.</p> <p>If <span class="code">Dest</span> is an atom, it is supposed to be the name of a registered process. The process referred to by the name is looked up at the time of delivery. No error is given if the name does not refer to a process.</p> <p>If <span class="code">Dest</span> is a pid, the timer will be automatically canceled if the process referred to by the pid is not alive, or when the process exits. This feature was introduced in erts version 5.4.11. Note that timers will not be automatically canceled when <span class="code">Dest</span> is an atom.</p> <p>See also <span class="bold_code"><a href="#start_timer-3">erlang:start_timer/3</a></span>, <span class="bold_code"><a href="#cancel_timer-1">erlang:cancel_timer/1</a></span>, and <span class="bold_code"><a href="#read_timer-1">erlang:read_timer/1</a></span>.</p> <p>Failure: <span class="code">badarg</span> if the arguments does not satisfy the requirements specified above.</p> </p></div> <p><a name="send_nosuspend-2"></a><span class="bold_code">erlang:send_nosuspend(Dest, Msg) -> boolean()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Dest = dst()</span></div> <div class="REFTYPES"><span class="bold_code">Msg = term()</span></div> <div class="REFTYPES"> <span class="bold_code">dst() = pid()<br> | port()<br> | (RegName :: atom())<br> | {RegName :: atom(), Node :: node()}</span><br> </div> </div></p> <div class="REFBODY"><p> <p>The same as <span class="bold_code"><a href="#send-3">erlang:send(Dest, Msg, [nosuspend])</a></span>, but returns <span class="code">true</span> if the message was sent and <span class="code">false</span> if the message was not sent because the sender would have had to be suspended.</p> <p>This function is intended for send operations towards an unreliable remote node without ever blocking the sending (Erlang) process. If the connection to the remote node (usually not a real Erlang node, but a node written in C or Java) is overloaded, this function <strong>will not send the message</strong> but return <span class="code">false</span> instead.</p> <p>The same happens, if <span class="code">Dest</span> refers to a local port that is busy. For all other destinations (allowed for the ordinary send operator <span class="code">'!'</span>) this function sends the message and returns <span class="code">true</span>.</p> <p>This function is only to be used in very rare circumstances where a process communicates with Erlang nodes that can disappear without any trace causing the TCP buffers and the drivers queue to be over-full before the node will actually be shut down (due to tick timeouts) by <span class="code">net_kernel</span>. The normal reaction to take when this happens is some kind of premature shutdown of the other node.</p> <p>Note that ignoring the return value from this function would result in <strong>unreliable</strong> message passing, which is contradictory to the Erlang programming model. The message is <strong>not</strong> sent if this function returns <span class="code">false</span>.</p> <p>Note also that in many systems, transient states of overloaded queues are normal. The fact that this function returns <span class="code">false</span> does not in any way mean that the other node is guaranteed to be non-responsive, it could be a temporary overload. Also a return value of <span class="code">true</span> does only mean that the message could be sent on the (TCP) channel without blocking, the message is not guaranteed to have arrived at the remote node. Also in the case of a disconnected non-responsive node, the return value is <span class="code">true</span> (mimics the behaviour of the <span class="code">!</span> operator). The expected behaviour as well as the actions to take when the function returns <span class="code">false</span> are application and hardware specific.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>Use with extreme care!</p> </p></div> </div> </p></div> <p><a name="send_nosuspend-3"></a><span class="bold_code">erlang:send_nosuspend(Dest, Msg, Options) -> boolean()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Dest = dst()</span></div> <div class="REFTYPES"><span class="bold_code">Msg = term()</span></div> <div class="REFTYPES"><span class="bold_code">Options = [noconnect]</span></div> <div class="REFTYPES"> <span class="bold_code">dst() = pid()<br> | port()<br> | (RegName :: atom())<br> | {RegName :: atom(), Node :: node()}</span><br> </div> </div></p> <div class="REFBODY"><p> <p>The same as <span class="bold_code"><a href="#send-3">erlang:send(Dest, Msg, [nosuspend | Options])</a></span>, but with boolean return value.</p> <p>This function behaves like <span class="bold_code"><a href="#send_nosuspend-2">erlang:send_nosuspend/2)</a></span>, but takes a third parameter, a list of options. The only currently implemented option is <span class="code">noconnect</span>. The option <span class="code">noconnect</span> makes the function return <span class="code">false</span> if the remote node is not currently reachable by the local node. The normal behaviour is to try to connect to the node, which may stall the process for a shorter period. The use of the <span class="code">noconnect</span> option makes it possible to be absolutely sure not to get even the slightest delay when sending to a remote process. This is especially useful when communicating with nodes who expect to always be the connecting part (i.e. nodes written in C or Java).</p> <p>Whenever the function returns <span class="code">false</span> (either when a suspend would occur or when <span class="code">noconnect</span> was specified and the node was not already connected), the message is guaranteed <strong>not</strong> to have been sent.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>Use with extreme care!</p> </p></div> </div> </p></div> <p><a name="set_cookie-2"></a><span class="bold_code">erlang:set_cookie(Node, Cookie) -> true</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Cookie = atom()</span></div> </div></p> <div class="REFBODY"><p> <p>Sets the magic cookie of <span class="code">Node</span> to the atom <span class="code">Cookie</span>. If <span class="code">Node</span> is the local node, the function also sets the cookie of all other unknown nodes to <span class="code">Cookie</span> (see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','doc/reference_manual','distributed.html');">Distributed Erlang</a></span> in the Erlang Reference Manual).</p> <p>Failure: <span class="code">function_clause</span> if the local node is not alive.</p> </p></div> <p><a name="setelement-3"><span class="bold_code">setelement(Index, Tuple1, Value) -> Tuple2</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Index = 1..tuple_size(Tuple1)</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Tuple1 = Tuple2 = tuple()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Value = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a tuple which is a copy of the argument <span class="code">Tuple1</span> with the element given by the integer argument <span class="code">Index</span> (the first element is the element with index 1) replaced by the argument <span class="code">Value</span>.</p> <div class="example"><pre> > <span class="bold_code">setelement(2, {10, green, bottles}, red).</span> {10,red,bottles}</pre></div> </p></div> <p><a name="size-1"><span class="bold_code">size(Item) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Item = tuple() | binary()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer which is the size of the argument <span class="code">Item</span>, which must be either a tuple or a binary.</p> <div class="example"><pre> > <span class="bold_code">size({morni, mulle, bwange}).</span> 3</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="spawn-1"></a><span class="bold_code">spawn(Fun) -> pid()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list <span class="code">[]</span>. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn-2"></a><span class="bold_code">spawn(Node, Fun) -> pid()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list <span class="code">[]</span> on <span class="code">Node</span>. If <span class="code">Node</span> does not exist, a useless pid is returned. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn-3"><span class="bold_code">spawn(Module, Function, Args) -> pid()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Module:Function</span> to <span class="code">Args</span>. The new process created will be placed in the system scheduler queue and be run some time later.</p> <p><span class="code">error_handler:undefined_function(Module, Function, Args)</span> is evaluated by the new process if <span class="code">Module:Function/Arity</span> does not exist (where <span class="code">Arity</span> is the length of <span class="code">Args</span>). The error handler can be redefined (see <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>). If <span class="code">error_handler</span> is undefined, or the user has redefined the default <span class="code">error_handler</span> its replacement is undefined, a failure with the reason <span class="code">undef</span> will occur.</p> <div class="example"><pre> > <span class="bold_code">spawn(speed, regulator, [high_speed, thin_cut]).</span> <0.13.1></pre></div> </p></div> <p><a name="spawn-4"></a><span class="bold_code">spawn(Node, Module, Function, Args) -> pid()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Module = module()</span></div> <div class="REFTYPES"><span class="bold_code">Function = atom()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Module:Function</span> to <span class="code">Args</span> on <span class="code">Node</span>. If <span class="code">Node</span> does not exists, a useless pid is returned. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_link-1"></a><span class="bold_code">spawn_link(Fun) -> pid()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list []. A link is created between the calling process and the new process, atomically. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_link-2"></a><span class="bold_code">spawn_link(Node, Fun) -> pid()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list [] on <span class="code">Node</span>. A link is created between the calling process and the new process, atomically. If <span class="code">Node</span> does not exist, a useless pid is returned (and due to the link, an exit signal with exit reason <span class="code">noconnection</span> will be received). Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_link-3"><span class="bold_code">spawn_link(Module, Function, Args) -> pid()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Module:Function</span> to <span class="code">Args</span>. A link is created between the calling process and the new process, atomically. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_link-4"></a><span class="bold_code">spawn_link(Node, Module, Function, Args) -> pid()</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Module = module()</span></div> <div class="REFTYPES"><span class="bold_code">Function = atom()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Module:Function</span> to <span class="code">Args</span> on <span class="code">Node</span>. A link is created between the calling process and the new process, atomically. If <span class="code">Node</span> does not exist, a useless pid is returned (and due to the link, an exit signal with exit reason <span class="code">noconnection</span> will be received). Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_monitor-1"></a><span class="bold_code">spawn_monitor(Fun) -> {pid(), reference()}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list [] and reference for a monitor created to the new process. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_monitor-3"></a><span class="bold_code">spawn_monitor(Module, Function, Args) -> {pid(), reference()}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Module = module()</span></div> <div class="REFTYPES"><span class="bold_code">Function = atom()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> </div></p> <div class="REFBODY"><p> <p>A new process is started by the application of <span class="code">Module:Function</span> to <span class="code">Args</span>, and the process is monitored at the same time. Returns the pid and a reference for the monitor. Otherwise works like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>.</p> </p></div> <p><a name="spawn_opt-2"></a><span class="bold_code">spawn_opt(Fun, Options) -> pid() | {pid(), reference()}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> <div class="REFTYPES"><span class="bold_code">Options = [Option]</span></div> <div class="REFTYPES"><span class="bold_code">Option = link<br> | monitor<br> | {priority, Level}<br> | {fullsweep_after, Number :: integer() >= 0}<br> | {min_heap_size, Size :: integer() >= 0}<br> | {min_bin_vheap_size, VSize :: integer() >= 0}</span></div> <div class="REFTYPES"><span class="bold_code">Level = low | normal | high</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list <span class="code">[]</span>. Otherwise works like <span class="bold_code"><a href="#spawn_opt-4">spawn_opt/4</a></span>.</p> <p>If the option <span class="code">monitor</span> is given, the newly created process will be monitored and both the pid and reference for the monitor will be returned.</p> </p></div> <p><a name="spawn_opt-3"></a><span class="bold_code">spawn_opt(Node, Fun, Options) -> pid() | {pid(), reference()}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Fun = function()</span></div> <div class="REFTYPES"><span class="bold_code">Options = [Option]</span></div> <div class="REFTYPES"><span class="bold_code">Option = link<br> | monitor<br> | {priority, Level}<br> | {fullsweep_after, Number :: integer() >= 0}<br> | {min_heap_size, Size :: integer() >= 0}<br> | {min_bin_vheap_size, VSize :: integer() >= 0}</span></div> <div class="REFTYPES"><span class="bold_code">Level = low | normal | high</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Fun</span> to the empty list <span class="code">[]</span> on <span class="code">Node</span>. If <span class="code">Node</span> does not exist, a useless pid is returned. Otherwise works like <span class="bold_code"><a href="#spawn_opt-4">spawn_opt/4</a></span>.</p> </p></div> <p><a name="spawn_opt-4"></a><span class="bold_code">spawn_opt(Module, Function, Args, Options) -><br> pid() | {pid(), reference()}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Module = module()</span></div> <div class="REFTYPES"><span class="bold_code">Function = atom()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> <div class="REFTYPES"><span class="bold_code">Options = [Option]</span></div> <div class="REFTYPES"><span class="bold_code">Option = link<br> | monitor<br> | {priority, Level}<br> | {fullsweep_after, Number :: integer() >= 0}<br> | {min_heap_size, Size :: integer() >= 0}<br> | {min_bin_vheap_size, VSize :: integer() >= 0}</span></div> <div class="REFTYPES"><span class="bold_code">Level = low | normal | high</span></div> </div></p> <div class="REFBODY"><p> <p>Works exactly like <span class="bold_code"><a href="#spawn-3">spawn/3</a></span>, except that an extra option list is given when creating the process.</p> <p>If the option <span class="code">monitor</span> is given, the newly created process will be monitored and both the pid and reference for the monitor will be returned.</p> <dl> <dt><strong><span class="code">link</span></strong></dt> <dd> <p>Sets a link to the parent process (like <span class="code">spawn_link/3</span> does).</p> </dd> <dt><strong><span class="code">monitor</span></strong></dt> <dd> <p>Monitor the new process (just like <span class="bold_code"><a href="#monitor-2">monitor/2</a></span> does).</p> </dd> <dt><strong><span class="code">{priority, Level}</span></strong></dt> <dd> <p>Sets the priority of the new process. Equivalent to executing <span class="bold_code"><a href="#process_flag_priority">process_flag(priority, Level)</a></span> in the start function of the new process, except that the priority will be set before the process is selected for execution for the first time. For more information on priorities see <span class="bold_code"><a href="#process_flag_priority">process_flag(priority, Level)</a></span>.</p> </dd> <dt><strong><span class="code">{fullsweep_after, Number}</span></strong></dt> <dd> <p>This option is only useful for performance tuning. In general, you should not use this option unless you know that there is problem with execution times and/or memory consumption, and you should measure to make sure that the option improved matters. </p> <p>The Erlang runtime system uses a generational garbage collection scheme, using an "old heap" for data that has survived at least one garbage collection. When there is no more room on the old heap, a fullsweep garbage collection will be done.</p> <p>The <span class="code">fullsweep_after</span> option makes it possible to specify the maximum number of generational collections before forcing a fullsweep even if there is still room on the old heap. Setting the number to zero effectively disables the general collection algorithm, meaning that all live data is copied at every garbage collection.</p> <p>Here are a few cases when it could be useful to change <span class="code">fullsweep_after</span>. Firstly, if binaries that are no longer used should be thrown away as soon as possible. (Set <span class="code">Number</span> to zero.) Secondly, a process that mostly have short-lived data will be fullsweeped seldom or never, meaning that the old heap will contain mostly garbage. To ensure a fullsweep once in a while, set <span class="code">Number</span> to a suitable value such as 10 or 20. Thirdly, in embedded systems with limited amount of RAM and no virtual memory, one might want to preserve memory by setting <span class="code">Number</span> to zero. (The value may be set globally, see <span class="bold_code"><a href="#system_flag-2">erlang:system_flag/2</a></span>.)</p> </dd> <dt><strong><span class="code">{min_heap_size, Size}</span></strong></dt> <dd> <p>This option is only useful for performance tuning. In general, you should not use this option unless you know that there is problem with execution times and/or memory consumption, and you should measure to make sure that the option improved matters. </p> <p>Gives a minimum heap size in words. Setting this value higher than the system default might speed up some processes because less garbage collection is done. Setting too high value, however, might waste memory and slow down the system due to worse data locality. Therefore, it is recommended to use this option only for fine-tuning an application and to measure the execution time with various <span class="code">Size</span> values.</p> </dd> <dt><strong><span class="code">{min_bin_vheap_size, VSize}</span></strong></dt> <dd> <p>This option is only useful for performance tuning. In general, you should not use this option unless you know that there is problem with execution times and/or memory consumption, and you should measure to make sure that the option improved matters. </p> <p>Gives a minimum binary virtual heap size in words. Setting this value higher than the system default might speed up some processes because less garbage collection is done. Setting too high value, however, might waste memory. Therefore, it is recommended to use this option only for fine-tuning an application and to measure the execution time with various <span class="code">VSize</span> values.</p> </dd> </dl> </p></div> <p><a name="spawn_opt-5"></a><span class="bold_code">spawn_opt(Node, Module, Function, Args, Options) -><br> pid() | {pid(), reference()}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Node = node()</span></div> <div class="REFTYPES"><span class="bold_code">Module = module()</span></div> <div class="REFTYPES"><span class="bold_code">Function = atom()</span></div> <div class="REFTYPES"><span class="bold_code">Args = [term()]</span></div> <div class="REFTYPES"><span class="bold_code">Options = [Option]</span></div> <div class="REFTYPES"><span class="bold_code">Option = link<br> | monitor<br> | {priority, Level}<br> | {fullsweep_after, Number :: integer() >= 0}<br> | {min_heap_size, Size :: integer() >= 0}<br> | {min_bin_vheap_size, VSize :: integer() >= 0}</span></div> <div class="REFTYPES"><span class="bold_code">Level = low | normal | high</span></div> </div></p> <div class="REFBODY"><p> <p>Returns the pid of a new process started by the application of <span class="code">Module:Function</span> to <span class="code">Args</span> on <span class="code">Node</span>. If <span class="code">Node</span> does not exist, a useless pid is returned. Otherwise works like <span class="bold_code"><a href="#spawn_opt-4">spawn_opt/4</a></span>.</p> </p></div> <p><a name="split_binary-2"><span class="bold_code">split_binary(Bin, Pos) -> {Bin1, Bin2}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Bin = Bin1 = Bin2 = binary()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Pos = 0..byte_size(Bin)</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a tuple containing the binaries which are the result of splitting <span class="code">Bin</span> into two parts at position <span class="code">Pos</span>. This is not a destructive operation. After the operation, there will be three binaries altogether.</p> <div class="example"><pre> > <span class="bold_code">B = list_to_binary("0123456789").</span> <<"0123456789">> > <span class="bold_code">byte_size(B).</span> 10 > <span class="bold_code">{B1, B2} = split_binary(B,3).</span> {<<"012">>,<<"3456789">>} > <span class="bold_code">byte_size(B1).</span> 3 > <span class="bold_code">byte_size(B2).</span> 7</pre></div> </p></div> <p><a name="start_timer-3"><span class="bold_code">erlang:start_timer(Time, Dest, Msg) -> TimerRef</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Time = integer() >= 0</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> 0 <= Time <= 4294967295</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Dest = LocalPid | RegName </span><br> </div> <div class="REFTYPES"> <span class="bold_code"> LocalPid = pid() (of a process, alive or dead, on the local node)</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> RegName = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Msg = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TimerRef = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p>Starts a timer which will send the message <span class="code">{timeout, TimerRef, Msg}</span> to <span class="code">Dest</span> after <span class="code">Time</span> milliseconds.</p> <p>If <span class="code">Dest</span> is an atom, it is supposed to be the name of a registered process. The process referred to by the name is looked up at the time of delivery. No error is given if the name does not refer to a process.</p> <p>If <span class="code">Dest</span> is a pid, the timer will be automatically canceled if the process referred to by the pid is not alive, or when the process exits. This feature was introduced in erts version 5.4.11. Note that timers will not be automatically canceled when <span class="code">Dest</span> is an atom.</p> <p>See also <span class="bold_code"><a href="#send_after-3">erlang:send_after/3</a></span>, <span class="bold_code"><a href="#cancel_timer-1">erlang:cancel_timer/1</a></span>, and <span class="bold_code"><a href="#read_timer-1">erlang:read_timer/1</a></span>.</p> <p>Failure: <span class="code">badarg</span> if the arguments does not satisfy the requirements specified above.</p> </p></div> <p><a name="statistics-1"><span class="bold_code">statistics(Type) -> Res</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Type, Res -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>All times are in milliseconds unless otherwise specified.</p> <p>Returns information about the system as specified by <span class="code">Type</span>:</p> <dl> <dt><strong><span class="code">context_switches</span></strong></dt> <dd> <p>Returns <span class="code">{ContextSwitches, 0}</span>, where <span class="code">ContextSwitches</span> is the total number of context switches since the system started.</p> </dd> <dt><strong><a name="statistics_exact_reductions"><span class="code">exact_reductions</span></a></strong></dt> <dd> <p>Returns <span class="code">{Total_Exact_Reductions, Exact_Reductions_Since_Last_Call}</span>.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p><p><span class="code">statistics(exact_reductions)</span> is a more expensive operation than <span class="bold_code"><a href="#statistics_reductions">statistics(reductions)</a></span> especially on an Erlang machine with SMP support.</p> </p></div> </div> </dd> <dt><strong><span class="code">garbage_collection</span></strong></dt> <dd> <p>Returns <span class="code">{Number_of_GCs, Words_Reclaimed, 0}</span>. This information may not be valid for all implementations.</p> <div class="example"><pre> > <span class="bold_code">statistics(garbage_collection).</span> {85,23961,0} </pre></div> </dd> <dt><strong><span class="code">io</span></strong></dt> <dd> <p>Returns <span class="code">{{input, Input}, {output, Output}}</span>, where <span class="code">Input</span> is the total number of bytes received through ports, and <span class="code">Output</span> is the total number of bytes output to ports.</p> </dd> <dt><strong><a name="statistics_reductions"><span class="code">reductions</span></a></strong></dt> <dd> <p>Returns <span class="code">{Total_Reductions, Reductions_Since_Last_Call}</span>.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>From erts version 5.5 (OTP release R11B) this value does not include reductions performed in current time slices of currently scheduled processes. If an exact value is wanted, use <span class="bold_code"><a href="#statistics_exact_reductions">statistics(exact_reductions)</a></span>.</p> </p></div> </div> <div class="example"><pre> > <span class="bold_code">statistics(reductions).</span> {2046,11} </pre></div> </dd> <dt><strong><span class="code">run_queue</span></strong></dt> <dd> <p>Returns the length of the run queue, that is, the number of processes that are ready to run.</p> </dd> <dt><strong><span class="code">runtime</span></strong></dt> <dd> <p>Returns <span class="code">{Total_Run_Time, Time_Since_Last_Call}</span>. Note that the run-time is the sum of the run-time for all threads in the Erlang run-time system and may therefore be greater than the wall-clock time.</p> <div class="example"><pre> > <span class="bold_code">statistics(runtime).</span> {1690,1620} </pre></div> </dd> <dt><strong><a name="statistics_scheduler_wall_time"><span class="code">scheduler_wall_time</span></a></strong></dt> <dd> <p>Returns a list of tuples with <span class="code">{SchedulerId, ActiveTime, TotalTime}</span>, where <span class="code">SchedulerId</span> is an integer id of the scheduler, <span class="code">ActiveTime</span> is the duration the scheduler has been busy, <span class="code">TotalTime</span> is the total time duration since <span class="bold_code"><a href="#system_flag_scheduler_wall_time">scheduler_wall_time</a></span> activation. The time unit is not defined and may be subject to change between releases, operating systems and system restarts. <span class="code">scheduler_wall_time</span> should only be used to calculate relative values for scheduler-utilization. <span class="code">ActiveTime</span> can never exceed <span class="code">TotalTime</span>. </p> <p>The definition of a busy scheduler is when it is not idle or not scheduling (selecting) a process or port, meaning; executing process code, executing linked-in-driver or NIF code, executing built-in-functions or any other runtime handling, garbage collecting or handling any other memory management. Note, a scheduler may also be busy even if the operating system has scheduled out the scheduler thread. </p> <p> Returns <span class="code">undefined</span> if the system flag <span class="bold_code"><a href="#system_flag_scheduler_wall_time"> scheduler_wall_time</a></span> is turned off. </p> <p>The list of scheduler information is unsorted and may appear in different order between calls. </p> <p>Using <span class="code">scheduler_wall_time</span> to calculate scheduler utilization.</p> <div class="example"><pre> > <span class="bold_code">erlang:system_flag(scheduler_wall_time, true).</span> false > <span class="bold_code">Ts0 = lists:sort(erlang:statistics(scheduler_wall_time)), ok.</span> ok </pre></div> <p>Some time later we will take another snapshot and calculate scheduler-utilization per scheduler.</p> <div class="example"><pre> > <span class="bold_code">Ts1 = lists:sort(erlang:statistics(scheduler_wall_time)), ok.</span> ok > <span class="bold_code">lists:map(fun({{I, A0, T0}, {I, A1, T1}}) -> {I, (A1 - A0)/(T1 - T0)} end, lists:zip(Ts0,Ts1)).</span> [{1,0.9743474730177548}, {2,0.9744843782751444}, {3,0.9995902361669045}, {4,0.9738012596572161}, {5,0.9717956667018103}, {6,0.9739235846420741}, {7,0.973237033077876}, {8,0.9741297293248656}] </pre></div> <p>Using the same snapshots to calculate a total scheduler-utilization.</p> <div class="example"><pre> > <span class="bold_code">{A, T} = lists:foldl(fun({{_, A0, T0}, {_, A1, T1}}, {Ai,Ti}) -> {Ai + (A1 - A0), Ti + (T1 - T0)} end, {0, 0}, lists:zip(Ts0,Ts1)), A/T.</span> 0.9769136803764825 </pre></div> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p><span class="code">scheduler_wall_time</span> is by default disabled. Use <span class="code">erlang:system_flag(scheduler_wall_time, true)</span> to enable it. </p> </p></div> </div> </dd> <dt><strong><span class="code">wall_clock</span></strong></dt> <dd> <p>Returns <span class="code">{Total_Wallclock_Time, Wallclock_Time_Since_Last_Call}</span>. <span class="code">wall_clock</span> can be used in the same manner as <span class="code">runtime</span>, except that real time is measured as opposed to runtime or CPU time.</p> </dd> </dl> </p></div> <p><a name="suspend_process-2"><span class="bold_code">erlang:suspend_process(Suspendee, OptList) -> boolean()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Suspendee = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">OptList = [Opt]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Opt = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Increases the suspend count on the process identified by <span class="code">Suspendee</span> and puts it in the suspended state if it isn't already in the suspended state. A suspended process will not be scheduled for execution until the process has been resumed. </p> <p>A process can be suspended by multiple processes and can be suspended multiple times by a single process. A suspended process will not leave the suspended state until its suspend count reach zero. The suspend count of <span class="code">Suspendee</span> is decreased when <span class="bold_code"><a href="#resume_process-1">erlang:resume_process(Suspendee)</a></span> is called by the same process that called <span class="code">erlang:suspend_process(Suspendee)</span>. All increased suspend counts on other processes acquired by a process will automatically be decreased when the process terminates.</p> <p>Currently the following options (<span class="code">Opt</span>s) are available:</p> <dl> <dt><strong><span class="code">asynchronous</span></strong></dt> <dd> A suspend request is sent to the process identified by <span class="code">Suspendee</span>. <span class="code">Suspendee</span> will eventually suspend unless it is resumed before it was able to suspend. The caller of <span class="code">erlang:suspend_process/2</span> will return immediately, regardless of whether the <span class="code">Suspendee</span> has suspended yet or not. Note that the point in time when the <span class="code">Suspendee</span> will actually suspend cannot be deduced from other events in the system. The only guarantee given is that the <span class="code">Suspendee</span> will <strong>eventually</strong> suspend (unless it is resumed). If the <span class="code">asynchronous</span> option has <strong>not</strong> been passed, the caller of <span class="code">erlang:suspend_process/2</span> will be blocked until the <span class="code">Suspendee</span> has actually suspended. </dd> <dt><strong><span class="code">unless_suspending</span></strong></dt> <dd> The process identified by <span class="code">Suspendee</span> will be suspended unless the calling process already is suspending the <span class="code">Suspendee</span>. If <span class="code">unless_suspending</span> is combined with the <span class="code">asynchronous</span> option, a suspend request will be sent unless the calling process already is suspending the <span class="code">Suspendee</span> or if a suspend request already has been sent and is in transit. If the calling process already is suspending the <span class="code">Suspendee</span>, or if combined with the <span class="code">asynchronous</span> option and a send request already is in transit, <span class="code">false</span> is returned and the suspend count on <span class="code">Suspendee</span> will remain unchanged. </dd> </dl> <p>If the suspend count on the process identified by <span class="code">Suspendee</span> was increased, <span class="code">true</span> is returned; otherwise, <span class="code">false</span> is returned.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging only.</p> </p></div> </div> <p>Failures:</p> <dl> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">Suspendee</span> isn't a process identifier. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If the process identified by <span class="code">Suspendee</span> is same the process as the process calling <span class="code">erlang:suspend_process/2</span>. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If the process identified by <span class="code">Suspendee</span> is not alive. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If the process identified by <span class="code">Suspendee</span> resides on another node. </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> If <span class="code">OptList</span> isn't a proper list of valid <span class="code">Opt</span>s. </dd> <dt><strong><span class="code">system_limit</span></strong></dt> <dd> If the process identified by <span class="code">Suspendee</span> has been suspended more times by the calling process than can be represented by the currently used internal data structures. The current system limit is larger than 2 000 000 000 suspends, and it will never be less than that. </dd> </dl> </p></div> <p><a name="suspend_process-1"></a><span class="bold_code">erlang:suspend_process(Suspendee) -> true</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Suspendee = pid()</span></div> </div></p> <div class="REFBODY"><p> <p>Suspends the process identified by <span class="code">Suspendee</span>. The same as calling <span class="bold_code"><a href="#suspend_process-2">erlang:suspend_process(Suspendee, [])</a></span>. For more information see the documentation of <span class="bold_code"><a href="#suspend_process-2">erlang:suspend_process/2</a></span>. </p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>This BIF is intended for debugging only.</p> </p></div> </div> </p></div> <p><a name="system_flag-2"><span class="bold_code">erlang:system_flag(Flag, Value) -> OldValue</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Flag, Value, OldValue -- see below</span><br> </div> </div> <div class="REFBODY"><p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p> <p>The <span class="bold_code"><a href="#system_flag_cpu_topology">cpu_topology</a></span>, and <span class="bold_code"><a href="#system_flag_scheduler_bind_type">scheduler_bind_type</a></span> <span class="code">Flag</span>s are <strong>deprecated</strong> and have been scheduled for removal in erts-5.10/OTP-R16.</p> </p></div> </div> <p>Sets various system properties of the Erlang node. Returns the old value of the flag.</p> <dl> <dt><strong><span class="code">erlang:system_flag(backtrace_depth, Depth)</span></strong></dt> <dd> <p>Sets the maximum depth of call stack back-traces in the exit reason element of <span class="code">'EXIT'</span> tuples.</p> </dd> <dt><strong><a name="system_flag_cpu_topology"><span class="code">erlang:system_flag(cpu_topology, CpuTopology)</span></a></strong></dt> <dd> <p><strong>NOTE:</strong> This argument is <strong>deprecated</strong> and scheduled for removal in erts-5.10/OTP-R16. Instead of using this argument you are advised to use the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sct');">+sct</a></span>. When this argument has been removed a final CPU topology to use will be determined at emulator boot time.</p> <p>Sets the user defined <span class="code">CpuTopology</span>. The user defined CPU topology will override any automatically detected CPU topology. By passing <span class="code">undefined</span> as <span class="code">CpuTopology</span> the system will revert back to the CPU topology automatically detected. The returned value equals the value returned from <span class="code">erlang:system_info(cpu_topology)</span> before the change was made. </p> <p>The CPU topology is used when binding schedulers to logical processors. If schedulers are already bound when the CPU topology is changed, the schedulers will be sent a request to rebind according to the new CPU topology. </p> <p>The user defined CPU topology can also be set by passing the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sct');">+sct</a></span> command line argument to <span class="code">erl</span>. </p> <p>For information on the <span class="code">CpuTopology</span> type and more, see the documentation of <span class="bold_code"><a href="#system_info_cpu_topology">erlang:system_info(cpu_topology)</a></span>, and the <span class="code">erl</span> <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sct');">+sct</a></span> and <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt</a></span> command line flags. </p> </dd> <dt><strong><span class="code">erlang:system_flag(fullsweep_after, Number)</span></strong></dt> <dd> <p><span class="code">Number</span> is a non-negative integer which indicates how many times generational garbage collections can be done without forcing a fullsweep collection. The value applies to new processes; processes already running are not affected.</p> <p>In low-memory systems (especially without virtual memory), setting the value to 0 can help to conserve memory.</p> <p>An alternative way to set this value is through the (operating system) environment variable <span class="code">ERL_FULLSWEEP_AFTER</span>.</p> </dd> <dt><strong><span class="code">erlang:system_flag(min_heap_size, MinHeapSize)</span></strong></dt> <dd> <p>Sets the default minimum heap size for processes. The size is given in words. The new <span class="code">min_heap_size</span> only effects processes spawned after the change of <span class="code">min_heap_size</span> has been made. The <span class="code">min_heap_size</span> can be set for individual processes by use of <span class="bold_code"><a href="#spawn_opt-4">spawn_opt/N</a></span> or <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>. </p> </dd> <dt><strong><span class="code">erlang:system_flag(min_bin_vheap_size, MinBinVHeapSize)</span></strong></dt> <dd> <p>Sets the default minimum binary virtual heap size for processes. The size is given in words. The new <span class="code">min_bin_vhheap_size</span> only effects processes spawned after the change of <span class="code">min_bin_vhheap_size</span> has been made. The <span class="code">min_bin_vheap_size</span> can be set for individual processes by use of <span class="bold_code"><a href="#spawn_opt-4">spawn_opt/N</a></span> or <span class="bold_code"><a href="#process_flag-2">process_flag/2</a></span>. </p> </dd> <dt><strong><a name="system_flag_multi_scheduling"><span class="code">erlang:system_flag(multi_scheduling, BlockState)</span></a></strong></dt> <dd> <p><span class="code">BlockState = block | unblock</span></p> <p>If multi-scheduling is enabled, more than one scheduler thread is used by the emulator. Multi-scheduling can be blocked. When multi-scheduling has been blocked, only one scheduler thread will schedule Erlang processes.</p> <p>If <span class="code">BlockState =:= block</span>, multi-scheduling will be blocked. If <span class="code">BlockState =:= unblock</span> and no-one else is blocking multi-scheduling and this process has only blocked one time, multi-scheduling will be unblocked. One process can block multi-scheduling multiple times. If a process has blocked multiple times, it has to unblock exactly as many times as it has blocked before it has released its multi-scheduling block. If a process that has blocked multi-scheduling exits, it will release its blocking of multi-scheduling.</p> <p>The return values are <span class="code">disabled</span>, <span class="code">blocked</span>, or <span class="code">enabled</span>. The returned value describes the state just after the call to <span class="code">erlang:system_flag(multi_scheduling, BlockState)</span> has been made. The return values are described in the documentation of <span class="bold_code"><a href="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</a></span>.</p> <p><strong>NOTE</strong>: Blocking of multi-scheduling should normally not be needed. If you feel that you need to block multi-scheduling, think through the problem at least a couple of times again. Blocking multi-scheduling should only be used as a last resort since it will most likely be a <strong>very inefficient</strong> way to solve the problem.</p> <p>See also <span class="bold_code"><a href="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</a></span>, <span class="bold_code"><a href="#system_info_multi_scheduling_blockers">erlang:system_info(multi_scheduling_blockers)</a></span>, and <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span>.</p> </dd> <dt><strong><a name="system_flag_scheduler_bind_type"><span class="code">erlang:system_flag(scheduler_bind_type, How)</span></a></strong></dt> <dd> <p><strong>NOTE:</strong> This argument is <strong>deprecated</strong> and scheduled for removal in erts-5.10/OTP-R16. Instead of using this argument you are advised to use the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt</a></span>. When this argument has been removed a final scheduler bind type to use will be determined at emulator boot time.</p> <p>Controls if and how schedulers are bound to logical processors.</p> <p>When <span class="code">erlang:system_flag(scheduler_bind_type, How)</span> is called, an asynchronous signal is sent to all schedulers online which causes them to try to bind or unbind as requested. <strong>NOTE:</strong> If a scheduler fails to bind, this will often be silently ignored. This since it isn't always possible to verify valid logical processor identifiers. If an error is reported, it will be reported to the <span class="code">error_logger</span>. If you want to verify that the schedulers actually have bound as requested, call <span class="bold_code"><a href="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</a></span>. </p> <p>Schedulers can currently only be bound on newer Linux, Solaris, FreeBSD, and Windows systems, but more systems will be supported in the future. </p> <p>In order for the runtime system to be able to bind schedulers, the CPU topology needs to be known. If the runtime system fails to automatically detect the CPU topology, it can be defined. For more information on how to define the CPU topology, see the <span class="code">erl</span> <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sct');">+sct</a></span> command line flag. </p> <p>The runtime system will by default <strong>not</strong> bind schedulers to logical processors. </p> <p><strong>NOTE:</strong> If the Erlang runtime system is the only operating system process that binds threads to logical processors, this improves the performance of the runtime system. However, if other operating system processes (as for example another Erlang runtime system) also bind threads to logical processors, there might be a performance penalty instead. In some cases this performance penalty might be severe. If this is the case, you are advised to not bind the schedulers.</p> <p>Schedulers can be bound in different ways. The <span class="code">How</span> argument determines how schedulers are bound. <span class="code">How</span> can currently be one of:</p> <dl> <dt><strong><span class="code">unbound</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt u</a></span>. </p></dd> <dt><strong><span class="code">no_spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt ns</a></span>. </p></dd> <dt><strong><span class="code">thread_spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt ts</a></span>. </p></dd> <dt><strong><span class="code">processor_spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt ps</a></span>. </p></dd> <dt><strong><span class="code">spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt s</a></span>. </p></dd> <dt><strong><span class="code">no_node_thread_spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt nnts</a></span>. </p></dd> <dt><strong><span class="code">no_node_processor_spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt nnps</a></span>. </p></dd> <dt><strong><span class="code">thread_no_node_processor_spread</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt tnnps</a></span>. </p></dd> <dt><strong><span class="code">default_bind</span></strong></dt> <dd><p>Same as the <span class="code">erl</span> command line argument <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt db</a></span>. </p></dd> </dl> <p>The value returned equals <span class="code">How</span> before the <span class="code">scheduler_bind_type</span> flag was changed.</p> <p>Failure:</p> <dl> <dt><strong><span class="code">notsup</span></strong></dt> <dd> <p>If binding of schedulers is not supported.</p> </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> <p>If <span class="code">How</span> isn't one of the documented alternatives.</p> </dd> <dt><strong><span class="code">badarg</span></strong></dt> <dd> <p>If no CPU topology information is available.</p> </dd> </dl> <p>The scheduler bind type can also be set by passing the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt</a></span> command line argument to <span class="code">erl</span>. </p> <p>For more information, see <span class="bold_code"><a href="#system_info_scheduler_bind_type">erlang:system_info(scheduler_bind_type)</a></span>, <span class="bold_code"><a href="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</a></span>, the <span class="code">erl</span> <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt</a></span> and <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sct');">+sct</a></span> command line flags. </p> </dd> <dt><strong><a name="system_flag_scheduler_wall_time"><span class="code">erlang:system_flag(scheduler_wall_time, Boolean)</span></a></strong></dt> <dd> <p>Turns on/off scheduler wall time measurements. </p> <p>For more information see, <span class="bold_code"><a href="#statistics_scheduler_wall_time">erlang:statistics(scheduler_wall_time)</a></span>. </p> </dd> <dt><strong><a name="system_flag_schedulers_online"><span class="code">erlang:system_flag(schedulers_online, SchedulersOnline)</span></a></strong></dt> <dd> <p>Sets the amount of schedulers online. Valid range is 1 <= SchedulerId <= erlang:system_info(schedulers). </p> <p>For more information see, <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span>, and <span class="bold_code"><a href="#system_info_schedulers_online">erlang:system_info(schedulers_online)</a></span>. </p> </dd> <dt><strong><span class="code">erlang:system_flag(trace_control_word, TCW)</span></strong></dt> <dd> <p>Sets the value of the node's trace control word to <span class="code">TCW</span>. <span class="code">TCW</span> should be an unsigned integer. For more information see documentation of the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','match_spec.html#set_tcw');">set_tcw</a></span> function in the match specification documentation in the ERTS User's Guide.</p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The <span class="code">schedulers</span> option has been removed as of erts version 5.5.3. The number of scheduler threads is determined at emulator boot time, and cannot be changed after that.</p> </p></div> </div> </p></div> <p><a name="system_info-1"><span class="bold_code">erlang:system_info(Type) -> Res</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Type, Res -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns various information about the current system (emulator) as specified by <span class="code">Type</span>:</p> <dl> <dt><strong><a name="system_info_allocated_areas"><span class="code">allocated_areas</span></a></strong></dt> <dd> <p>Returns a list of tuples with information about miscellaneous allocated memory areas.</p> <p>Each tuple contains an atom describing type of memory as first element and amount of allocated memory in bytes as second element. In those cases when there is information present about allocated and used memory, a third element is present. This third element contains the amount of used memory in bytes.</p> <p><span class="code">erlang:system_info(allocated_areas)</span> is intended for debugging, and the content is highly implementation dependent. The content of the results will therefore change when needed without prior notice.</p> <p><strong>Note:</strong> The sum of these values is <strong>not</strong> the total amount of memory allocated by the emulator. Some values are part of other values, and some memory areas are not part of the result. If you are interested in the total amount of memory allocated by the emulator see <span class="bold_code"><a href="#memory-0">erlang:memory/0,1</a></span>.</p> </dd> <dt><strong><a name="system_info_allocator"><span class="code">allocator</span></a></strong></dt> <dd> <p>Returns <span class="code">{Allocator, Version, Features, Settings}.</span></p> <p>Types:</p> <ul> <li><span class="code">Allocator = undefined | glibc</span></li> <li><span class="code">Version = [integer()]</span></li> <li><span class="code">Features = [atom()]</span></li> <li><span class="code">Settings = [{Subsystem, [{Parameter, Value}]}]</span></li> <li><span class="code">Subsystem = atom()</span></li> <li><span class="code">Parameter = atom()</span></li> <li><span class="code">Value = term()</span></li> </ul> <p>Explanation:</p> <ul> <li> <p><span class="code">Allocator</span> corresponds to the <span class="code">malloc()</span> implementation used. If <span class="code">Allocator</span> equals <span class="code">undefined</span>, the <span class="code">malloc()</span> implementation used could not be identified. Currently <span class="code">glibc</span> can be identified.</p> </li> <li> <p><span class="code">Version</span> is a list of integers (but not a string) representing the version of the <span class="code">malloc()</span> implementation used.</p> </li> <li> <p><span class="code">Features</span> is a list of atoms representing allocation features used.</p> </li> <li> <p><span class="code">Settings</span> is a list of subsystems, their configurable parameters, and used values. Settings may differ between different combinations of platforms, allocators, and allocation features. Memory sizes are given in bytes.</p> </li> </ul> <p>See also "System Flags Effecting erts_alloc" in <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html#flags');">erts_alloc(3)</a></span>.</p> </dd> <dt><strong><a name="system_info_alloc_util_allocators"><span class="code">alloc_util_allocators</span></a></strong></dt> <dd> <p>Returns a list of the names of all allocators using the ERTS internal <span class="code">alloc_util</span> framework as atoms. For more information see the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html#alloc_util');">"the alloc_util framework" section in the erts_alloc(3)</a></span> documentation. </p> </dd> <dt><strong><a name="system_info_allocator_tuple"><span class="code">{allocator, Alloc}</span></a></strong></dt> <dd> <p>Returns information about the specified allocator. As of erts version 5.6.1 the return value is a list of <span class="code">{instance, InstanceNo, InstanceInfo}</span> tuples where <span class="code">InstanceInfo</span> contains information about a specific instance of the allocator. If <span class="code">Alloc</span> is not a recognized allocator, <span class="code">undefined</span> is returned. If <span class="code">Alloc</span> is disabled, <span class="code">false</span> is returned.</p> <p><strong>Note:</strong> The information returned is highly implementation dependent and may be changed, or removed at any time without prior notice. It was initially intended as a tool when developing new allocators, but since it might be of interest for others it has been briefly documented.</p> <p>The recognized allocators are listed in <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erts_alloc.html');">erts_alloc(3)</a></span>. After reading the <span class="code">erts_alloc(3)</span> documentation, the returned information should more or less speak for itself. But it can be worth explaining some things. Call counts are presented by two values. The first value is giga calls, and the second value is calls. <span class="code">mbcs</span>, and <span class="code">sbcs</span> are abbreviations for, respectively, multi-block carriers, and single-block carriers. Sizes are presented in bytes. When it is not a size that is presented, it is the amount of something. Sizes and amounts are often presented by three values, the first is current value, the second is maximum value since the last call to <span class="code">erlang:system_info({allocator, Alloc})</span>, and the third is maximum value since the emulator was started. If only one value is present, it is the current value. <span class="code">fix_alloc</span> memory block types are presented by two values. The first value is memory pool size and the second value used memory size.</p> </dd> <dt><strong><a name="system_info_allocator_sizes"><span class="code">{allocator_sizes, Alloc}</span></a></strong></dt> <dd> <p>Returns various size information for the specified allocator. The information returned is a subset of the information returned by <span class="bold_code"><a href="#system_info_allocator_tuple">erlang:system_info({allocator, Alloc})</a></span>. </p> </dd> <dt><strong><span class="code">build_type</span></strong></dt> <dd> <p>Returns an atom describing the build type of the runtime system. This is normally the atom <span class="code">opt</span> for optimized. Other possible return values are <span class="code">debug</span>, <span class="code">purify</span>, <span class="code">quantify</span>, <span class="code">purecov</span>, <span class="code">gcov</span>, <span class="code">valgrind</span>, <span class="code">gprof</span>, and <span class="code">lcnt</span>. Possible return values may be added and/or removed at any time without prior notice. </p> </dd> <dt><strong><span class="code">c_compiler_used</span></strong></dt> <dd> <p>Returns a two-tuple describing the C compiler used when compiling the runtime system. The first element is an atom describing the name of the compiler, or <span class="code">undefined</span> if unknown. The second element is a term describing the version of the compiler, or <span class="code">undefined</span> if unknown. </p> </dd> <dt><strong><span class="code">check_io</span></strong></dt> <dd> <p>Returns a list containing miscellaneous information regarding the emulators internal I/O checking. Note, the content of the returned list may vary between platforms and over time. The only thing guaranteed is that a list is returned.</p> </dd> <dt><strong><span class="code">compat_rel</span></strong></dt> <dd> <p>Returns the compatibility mode of the local node as an integer. The integer returned represents the Erlang/OTP release which the current emulator has been set to be backward compatible with. The compatibility mode can be configured at startup by using the command line flag <span class="code">+R</span>, see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#compat_rel');">erl(1)</a></span>.</p> </dd> <dt><strong><a name="system_info_cpu_topology"><span class="code">cpu_topology</span></a></strong></dt> <dd> <p>Returns the <span class="code">CpuTopology</span> which currently is used by the emulator. The CPU topology is used when binding schedulers to logical processors. The CPU topology used is the <span class="bold_code"><a href="erlang.html#system_info_cpu_topology_defined">user defined CPU topology</a></span> if such exists; otherwise, the <span class="bold_code"><a href="erlang.html#system_info_cpu_topology_detected">automatically detected CPU topology</a></span> if such exists. If no CPU topology exists, <span class="code">undefined</span> is returned.</p> <p>Types:</p> <ul> <li><span class="code">CpuTopology = LevelEntryList | undefined</span></li> <li> <span class="code">LevelEntryList = [LevelEntry]</span> (all <span class="code">LevelEntry</span>s of a <span class="code">LevelEntryList</span> must contain the same <span class="code">LevelTag</span>, except on the top level where both <span class="code">node</span> and <span class="code">processor</span> <span class="code">LevelTag</span>s may co-exist)</li> <li> <span class="code">LevelEntry = {LevelTag, SubLevel} | {LevelTag, InfoList, SubLevel}</span> (<span class="code">{LevelTag, SubLevel} == {LevelTag, [], SubLevel}</span>)</li> <li> <span class="code">LevelTag = node|processor|core|thread</span> (more <span class="code">LevelTag</span>s may be introduced in the future)</li> <li><span class="code">SubLevel = [LevelEntry] | LogicalCpuId</span></li> <li><span class="code">LogicalCpuId = {logical, integer()}</span></li> <li> <span class="code">InfoList = []</span> (the <span class="code">InfoList</span> may be extended in the future)</li> </ul> <p><span class="code">node</span> refers to NUMA (non-uniform memory access) nodes, and <span class="code">thread</span> refers to hardware threads (e.g. Intels hyper-threads).</p> <p>A level in the <span class="code">CpuTopology</span> term can be omitted if only one entry exists and the <span class="code">InfoList</span> is empty. </p> <p><span class="code">thread</span> can only be a sub level to <span class="code">core</span>. <span class="code">core</span> can be a sub level to either <span class="code">processor</span> or <span class="code">node</span>. <span class="code">processor</span> can either be on the top level or a sub level to <span class="code">node</span>. <span class="code">node</span> can either be on the top level or a sub level to <span class="code">processor</span>. That is, NUMA nodes can be processor internal or processor external. A CPU topology can consist of a mix of processor internal and external NUMA nodes, as long as each logical CPU belongs to one and only one NUMA node. Cache hierarchy is not part of the <span class="code">CpuTopology</span> type yet, but will be in the future. Other things may also make it into the CPU topology in the future. In other words, expect the <span class="code">CpuTopology</span> type to change. </p> </dd> <dt><strong><a name="system_info_cpu_topology_defined"><span class="code">{cpu_topology, defined}</span></a></strong></dt> <dd> <p>Returns the user defined <span class="code">CpuTopology</span>. For more information see the documentation of the <span class="code">erl</span> <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sct');">+sct</a></span> command line flag, and the documentation of the <span class="bold_code"><a href="#system_info_cpu_topology">cpu_topology</a></span> argument. </p> </dd> <dt><strong><a name="system_info_cpu_topology_detected"><span class="code">{cpu_topology, detected}</span></a></strong></dt> <dd> <p>Returns the automatically detected <span class="code">CpuTopology</span>. The emulator currently only detects the CPU topology on some newer Linux, Solaris, FreeBSD, and Windows systems. On Windows system with more than 32 logical processors the CPU topology is not detected. </p> <p>For more information see the documentation of the <span class="bold_code"><a href="#system_info_cpu_topology">cpu_topology</a></span> argument. </p> </dd> <dt><strong><span class="code">{cpu_topology, used}</span></strong></dt> <dd> <p>Returns the <span class="code">CpuTopology</span> which is used by the emulator. For more information see the documentation of the <span class="bold_code"><a href="#system_info_cpu_topology">cpu_topology</a></span> argument. </p> </dd> <dt><strong><span class="code">creation</span></strong></dt> <dd> <p>Returns the creation of the local node as an integer. The creation is changed when a node is restarted. The creation of a node is stored in process identifiers, port identifiers, and references. This makes it (to some extent) possible to distinguish between identifiers from different incarnations of a node. Currently valid creations are integers in the range 1..3, but this may (probably will) change in the future. If the node is not alive, 0 is returned.</p> </dd> <dt><strong><span class="code">debug_compiled</span></strong></dt> <dd> <p>Returns <span class="code">true</span> if the emulator has been debug compiled; otherwise, <span class="code">false</span>. </p> </dd> <dt><strong><span class="code">dist</span></strong></dt> <dd> <p>Returns a binary containing a string of distribution information formatted as in Erlang crash dumps. For more information see the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','crash_dump.html');">"How to interpret the Erlang crash dumps"</a></span> chapter in the ERTS User's Guide.</p> </dd> <dt><strong><span class="code">dist_ctrl</span></strong></dt> <dd> <p>Returns a list of tuples <span class="code">{Node, ControllingEntity}</span>, one entry for each connected remote node. The <span class="code">Node</span> is the name of the node and the <span class="code">ControllingEntity</span> is the port or pid responsible for the communication to that node. More specifically, the <span class="code">ControllingEntity</span> for nodes connected via TCP/IP (the normal case) is the socket actually used in communication with the specific node.</p> </dd> <dt><strong><span class="code">driver_version</span></strong></dt> <dd> <p>Returns a string containing the erlang driver version used by the runtime system. It will be on the form <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl_driver.html#version_management');">"<major ver>.<minor ver>"</a></span>.</p> </dd> <dt><strong><span class="code">dynamic_trace</span></strong></dt> <dd> <p>Returns an atom describing the dynamic trace framework compiled into the virtual machine. It can currently be either <span class="code">dtrace</span>, <span class="code">systemtap</span> or <span class="code">none</span>. For a commercial or standard build, this is always <span class="code">none</span>, the other return values indicate a custom configuration (e.g. <span class="code">./configure --with-dynamic-trace=dtrace</span>). See the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','runtime_tools','dyntrace.html');">dyntrace </a></span> manual page and the <span class="code">README.dtrace</span>/<span class="code">README.systemtap</span> files in the Erlang source code top directory for more information about dynamic tracing.</p> </dd> <dt><strong><span class="code">dynamic_trace_probes</span></strong></dt> <dd> <p>Returns a <span class="code">boolean()</span> indicating if dynamic trace probes (either dtrace or systemtap) are built into the emulator. This can only be <span class="code">true</span> if the virtual machine was built for dynamic tracing (i.e. <span class="code">system_info(dynamic_trace)</span> returns <span class="code">dtrace</span> or <span class="code">systemtap</span>).</p> </dd> <dt><strong><span class="code">elib_malloc</span></strong></dt> <dd> <p>This option will be removed in a future release. The return value will always be <span class="code">false</span> since the elib_malloc allocator has been removed.</p> </dd> <dt><strong><a name="system_info_dist_buf_busy_limit"><span class="code">dist_buf_busy_limit</span></a></strong></dt> <dd> <p>Returns the value of the distribution buffer busy limit in bytes. This limit can be set on startup by passing the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+zdbbl');">+zdbbl</a></span> command line flag to <span class="code">erl</span>.</p> </dd> <dt><strong><span class="code">fullsweep_after</span></strong></dt> <dd> <p>Returns <span class="code">{fullsweep_after, integer()}</span> which is the <span class="code">fullsweep_after</span> garbage collection setting used by default. For more information see <span class="code">garbage_collection</span> described below.</p> </dd> <dt><strong><span class="code">garbage_collection</span></strong></dt> <dd> <p>Returns a list describing the default garbage collection settings. A process spawned on the local node by a <span class="code">spawn</span> or <span class="code">spawn_link</span> will use these garbage collection settings. The default settings can be changed by use of <span class="bold_code"><a href="#system_flag-2">system_flag/2</a></span>. <span class="bold_code"><a href="#spawn_opt-4">spawn_opt/4</a></span> can spawn a process that does not use the default settings.</p> </dd> <dt><strong><span class="code">heap_sizes</span></strong></dt> <dd> <p>Returns a list of integers representing valid heap sizes in words. All Erlang heaps are sized from sizes in this list.</p> </dd> <dt><strong><span class="code">heap_type</span></strong></dt> <dd> <p>Returns the heap type used by the current emulator. Currently only the following heap type exists:</p> <dl> <dt><strong><span class="code">private</span></strong></dt> <dd> <p>Each process has a heap reserved for its use and no references between heaps of different processes are allowed. Messages passed between processes are copied between heaps.</p> </dd> </dl> </dd> <dt><strong><span class="code">info</span></strong></dt> <dd> <p>Returns a binary containing a string of miscellaneous system information formatted as in Erlang crash dumps. For more information see the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','crash_dump.html');">"How to interpret the Erlang crash dumps"</a></span> chapter in the ERTS User's Guide.</p> </dd> <dt><strong><span class="code">kernel_poll</span></strong></dt> <dd> <p>Returns <span class="code">true</span> if the emulator uses some kind of kernel-poll implementation; otherwise, <span class="code">false</span>.</p> </dd> <dt><strong><span class="code">loaded</span></strong></dt> <dd> <p>Returns a binary containing a string of loaded module information formatted as in Erlang crash dumps. For more information see the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','crash_dump.html');">"How to interpret the Erlang crash dumps"</a></span> chapter in the ERTS User's Guide.</p> </dd> <dt><strong><a name="logical_processors"><span class="code">logical_processors</span></a></strong></dt> <dd> <p>Returns the detected number of logical processors configured on the system. The return value is either an integer, or the atom <span class="code">unknown</span> if the emulator wasn't able to detect logical processors configured. </p> </dd> <dt><strong><a name="logical_processors_available"><span class="code">logical_processors_available</span></a></strong></dt> <dd> <p>Returns the detected number of logical processors available to the Erlang runtime system. The return value is either an integer, or the atom <span class="code">unknown</span> if the emulator wasn't able to detect logical processors available. The number of logical processors available is less than or equal to the number of <span class="bold_code"><a href="#logical_processors_online">logical processors online</a></span>. </p> </dd> <dt><strong><a name="logical_processors_online"><span class="code">logical_processors_online</span></a></strong></dt> <dd> <p>Returns the detected number of logical processors online on the system. The return value is either an integer, or the atom <span class="code">unknown</span> if the emulator wasn't able to detect logical processors online. The number of logical processors online is less than or equal to the number of <span class="bold_code"><a href="#logical_processors">logical processors configured</a></span>. </p> </dd> <dt><strong><span class="code">machine</span></strong></dt> <dd> <p>Returns a string containing the Erlang machine name.</p> </dd> <dt><strong><span class="code">min_heap_size</span></strong></dt> <dd> <p>Returns <span class="code">{min_heap_size, MinHeapSize}</span> where <span class="code">MinHeapSize</span> is the current system wide minimum heap size for spawned processes.</p> </dd> <dt><strong><span class="code">min_bin_vheap_size</span></strong></dt> <dd> <p>Returns <span class="code">{min_bin_vheap_size, MinBinVHeapSize}</span> where <span class="code">MinBinVHeapSize</span> is the current system wide minimum binary virtual heap size for spawned processes.</p> </dd> <dt><strong><span class="code">modified_timing_level</span></strong></dt> <dd> <p>Returns the modified timing level (an integer) if modified timing has been enabled; otherwise, <span class="code">undefined</span>. See the <span class="code">+T</span> command line flag in the documentation of the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+T');">erl(1)</a></span> command for more information on modified timing.</p> </dd> <dt><strong><a name="system_info_multi_scheduling"><span class="code">multi_scheduling</span></a></strong></dt> <dd> <p>Returns <span class="code">disabled</span>, <span class="code">blocked</span>, or <span class="code">enabled</span>. A description of the return values:</p> <dl> <dt><strong><span class="code">disabled</span></strong></dt> <dd> <p>The emulator has only one scheduler thread. The emulator does not have SMP support, or have been started with only one scheduler thread.</p> </dd> <dt><strong><span class="code">blocked</span></strong></dt> <dd> <p>The emulator has more than one scheduler thread, but all scheduler threads but one have been blocked, i.e., only one scheduler thread will schedule Erlang processes and execute Erlang code.</p> </dd> <dt><strong><span class="code">enabled</span></strong></dt> <dd> <p>The emulator has more than one scheduler thread, and no scheduler threads have been blocked, i.e., all available scheduler threads will schedule Erlang processes and execute Erlang code.</p> </dd> </dl> <p>See also <span class="bold_code"><a href="#system_flag_multi_scheduling">erlang:system_flag(multi_scheduling, BlockState)</a></span>, <span class="bold_code"><a href="#system_info_multi_scheduling_blockers">erlang:system_info(multi_scheduling_blockers)</a></span>, and <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span>.</p> </dd> <dt><strong><a name="system_info_multi_scheduling_blockers"><span class="code">multi_scheduling_blockers</span></a></strong></dt> <dd> <p>Returns a list of <span class="code">PID</span>s when multi-scheduling is blocked; otherwise, the empty list. The <span class="code">PID</span>s in the list is <span class="code">PID</span>s of the processes currently blocking multi-scheduling. A <span class="code">PID</span> will only be present once in the list, even if the corresponding process has blocked multiple times.</p> <p>See also <span class="bold_code"><a href="#system_flag_multi_scheduling">erlang:system_flag(multi_scheduling, BlockState)</a></span>, <span class="bold_code"><a href="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</a></span>, and <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span>.</p> </dd> <dt><strong><a name="system_info_otp_release"><span class="code">otp_release</span></a></strong></dt> <dd> <p>Returns a string containing the OTP release number.</p> </dd> <dt><strong><span class="code">process_count</span></strong></dt> <dd> <p>Returns the number of processes currently existing at the local node as an integer. The same value as <span class="code">length(processes())</span> returns.</p> </dd> <dt><strong><span class="code">process_limit</span></strong></dt> <dd> <p>Returns the maximum number of concurrently existing processes at the local node as an integer. This limit can be configured at startup by using the command line flag <span class="code">+P</span>, see <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#max_processes');">erl(1)</a></span>.</p> </dd> <dt><strong><span class="code">procs</span></strong></dt> <dd> <p>Returns a binary containing a string of process and port information formatted as in Erlang crash dumps. For more information see the <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','crash_dump.html');">"How to interpret the Erlang crash dumps"</a></span> chapter in the ERTS User's Guide.</p> </dd> <dt><strong><a name="system_info_scheduler_bind_type"><span class="code">scheduler_bind_type</span></a></strong></dt> <dd> <p>Returns information on how user has requested schedulers to be bound or not bound.</p> <p><strong>NOTE:</strong> Even though user has requested schedulers to be bound, they might have silently failed to bind. In order to inspect actual scheduler bindings call <span class="bold_code"><a href="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</a></span>. </p> <p>For more information, see the <span class="code">erl</span> <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt</a></span> command line argument, and <span class="bold_code"><a href="#system_info_scheduler_bindings">erlang:system_info(scheduler_bindings)</a></span>. </p> </dd> <dt><strong><a name="system_info_scheduler_bindings"><span class="code">scheduler_bindings</span></a></strong></dt> <dd> <p>Returns information on currently used scheduler bindings.</p> <p>A tuple of a size equal to <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span> is returned. The elements of the tuple are integers or the atom <span class="code">unbound</span>. Logical processor identifiers are represented as integers. The <span class="code">N</span>th element of the tuple equals the current binding for the scheduler with the scheduler identifier equal to <span class="code">N</span>. E.g., if the schedulers have been bound, <span class="code">element(erlang:system_info(scheduler_id), erlang:system_info(scheduler_bindings))</span> will return the identifier of the logical processor that the calling process is executing on. </p> <p>Note that only schedulers online can be bound to logical processors.</p> <p>For more information, see the <span class="code">erl</span> <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl.html#+sbt');">+sbt</a></span> command line argument, <span class="bold_code"><a href="#system_info_schedulers_online">erlang:system_info(schedulers_online)</a></span>. </p> </dd> <dt><strong><a name="system_info_scheduler_id"><span class="code">scheduler_id</span></a></strong></dt> <dd> <p>Returns the scheduler id (<span class="code">SchedulerId</span>) of the scheduler thread that the calling process is executing on. <span class="code">SchedulerId</span> is a positive integer; where <span class="code">1 <= SchedulerId <= erlang:system_info(schedulers)</span>. See also <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span>.</p> </dd> <dt><strong><a name="system_info_schedulers"><span class="code">schedulers</span></a></strong></dt> <dd> <p>Returns the number of scheduler threads used by the emulator. Scheduler threads online schedules Erlang processes and Erlang ports, and execute Erlang code and Erlang linked in driver code.</p> <p>The number of scheduler threads is determined at emulator boot time and cannot be changed after that. The amount of schedulers online can however be changed at any time.</p> <p>See also <span class="bold_code"><a href="#system_flag_schedulers_online">erlang:system_flag(schedulers_online, SchedulersOnline)</a></span>, <span class="bold_code"><a href="#system_info_schedulers_online">erlang:system_info(schedulers_online)</a></span>, <span class="bold_code"><a href="#system_info_scheduler_id">erlang:system_info(scheduler_id)</a></span>, <span class="bold_code"><a href="#system_flag_multi_scheduling">erlang:system_flag(multi_scheduling, BlockState)</a></span>, <span class="bold_code"><a href="#system_info_multi_scheduling">erlang:system_info(multi_scheduling)</a></span>, and and <span class="bold_code"><a href="#system_info_multi_scheduling_blockers">erlang:system_info(multi_scheduling_blockers)</a></span>.</p> </dd> <dt><strong><a name="system_info_schedulers_online"><span class="code">schedulers_online</span></a></strong></dt> <dd> <p>Returns the amount of schedulers online. The scheduler identifiers of schedulers online satisfy the following relationship: <span class="code">1 <= SchedulerId <= erlang:system_info(schedulers_online)</span>. </p> <p>For more information, see <span class="bold_code"><a href="#system_info_schedulers">erlang:system_info(schedulers)</a></span>, and <span class="bold_code"><a href="#system_flag_schedulers_online">erlang:system_flag(schedulers_online, SchedulersOnline)</a></span>. </p> </dd> <dt><strong><span class="code">smp_support</span></strong></dt> <dd> <p>Returns <span class="code">true</span> if the emulator has been compiled with smp support; otherwise, <span class="code">false</span>.</p> </dd> <dt><strong><span class="code">system_version</span></strong></dt> <dd> <p>Returns a string containing version number and some important properties such as the number of schedulers.</p> </dd> <dt><strong><span class="code">system_architecture</span></strong></dt> <dd> <p>Returns a string containing the processor and OS architecture the emulator is built for.</p> </dd> <dt><strong><span class="code">threads</span></strong></dt> <dd> <p>Returns <span class="code">true</span> if the emulator has been compiled with thread support; otherwise, <span class="code">false</span> is returned.</p> </dd> <dt><strong><a name="system_info_thread_pool_size"><span class="code">thread_pool_size</span></a></strong></dt> <dd> <p>Returns the number of async threads in the async thread pool used for asynchronous driver calls (<span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','erl_driver.html#driver_async');">driver_async()</a></span>) as an integer.</p> </dd> <dt><strong><span class="code">trace_control_word</span></strong></dt> <dd> <p>Returns the value of the node's trace control word. For more information see documentation of the function <span class="code">get_tcw</span> in "Match Specifications in Erlang", <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','erts','match_spec.html#get_tcw');">ERTS User's Guide</a></span>.</p> </dd> <dt><strong><a name="update_cpu_info"><span class="code">update_cpu_info</span></a></strong></dt> <dd> <p>The runtime system rereads the CPU information available and updates its internally stored information about the <span class="bold_code"><a href="#system_info_cpu_topology_detected">detected CPU topology</a></span> and the amount of logical processors <span class="bold_code"><a href="#logical_processors">configured</a></span>, <span class="bold_code"><a href="#logical_processors_online">online</a></span>, and <span class="bold_code"><a href="#logical_processors_available">available</a></span>. If the CPU information has changed since the last time it was read, the atom <span class="code">changed</span> is returned; otherwise, the atom <span class="code">unchanged</span> is returned. If the CPU information has changed you probably want to <span class="bold_code"><a href="#system_flag_schedulers_online">adjust the amount of schedulers online</a></span>. You typically want to have as many schedulers online as <span class="bold_code"><a href="#logical_processors_available">logical processors available</a></span>. </p> </dd> <dt><strong><a name="system_info_version"><span class="code">version</span></a></strong></dt> <dd> <p>Returns a string containing the version number of the emulator.</p> </dd> <dt><strong><span class="code">wordsize</span></strong></dt> <dd> <p>Same as <span class="code">{wordsize, internal}.</span></p> </dd> <dt><strong><span class="code">{wordsize, internal}</span></strong></dt> <dd> <p>Returns the size of Erlang term words in bytes as an integer, i.e. on a 32-bit architecture 4 is returned, and on a pure 64-bit architecture 8 is returned. On a halfword 64-bit emulator, 4 is returned, as the Erlang terms are stored using a virtual wordsize of half the system's wordsize.</p> </dd> <dt><strong><span class="code">{wordsize, external}</span></strong></dt> <dd> <p>Returns the true wordsize of the emulator, i.e. the size of a pointer, in bytes as an integer. On a pure 32-bit architecture 4 is returned, on both a halfword and pure 64-bit architecture, 8 is returned.</p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The <span class="code">scheduler</span> argument has changed name to <span class="code">scheduler_id</span>. This in order to avoid mixup with the <span class="code">schedulers</span> argument. The <span class="code">scheduler</span> argument was introduced in ERTS version 5.5 and renamed in ERTS version 5.5.1.</p> </p></div> </div> </p></div> <p><a name="system_monitor-0"><span class="bold_code">erlang:system_monitor() -> MonSettings</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MonSettings -> {MonitorPid, Options} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> MonitorPid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Option = {long_gc, Time} | {large_heap, Size} | busy_port | busy_dist_port</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Time = Size = integer()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the current system monitoring settings set by <span class="bold_code"><a href="#system_monitor-2">erlang:system_monitor/2</a></span> as <span class="code">{MonitorPid, Options}</span>, or <span class="code">undefined</span> if there are no settings. The order of the options may be different from the one that was set.</p> </p></div> <p><a name="system_monitor-1"><span class="bold_code">erlang:system_monitor(undefined | {MonitorPid, Options}) -> MonSettings</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MonitorPid, Options, MonSettings -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>When called with the argument <span class="code">undefined</span>, all system performance monitoring settings are cleared.</p> <p>Calling the function with <span class="code">{MonitorPid, Options}</span> as argument, is the same as calling <span class="bold_code"><a href="#system_monitor-2">erlang:system_monitor(MonitorPid, Options)</a></span>.</p> <p>Returns the previous system monitor settings just like <span class="bold_code"><a href="#system_monitor-0">erlang:system_monitor/0</a></span>.</p> </p></div> <p><a name="system_monitor-2"><span class="bold_code">erlang:system_monitor(MonitorPid, [Option]) -> MonSettings</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MonitorPid = pid()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = {long_gc, Time} | {large_heap, Size} | busy_port | busy_dist_port</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Time = Size = integer()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MonSettings = {OldMonitorPid, [Option]}</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> OldMonitorPid = pid()</span><br> </div> </div> <div class="REFBODY"><p> <p>Sets system performance monitoring options. <span class="code">MonitorPid</span> is a local pid that will receive system monitor messages, and the second argument is a list of monitoring options:</p> <dl> <dt><strong><span class="code">{long_gc, Time}</span></strong></dt> <dd> <p>If a garbage collection in the system takes at least <span class="code">Time</span> wallclock milliseconds, a message <span class="code">{monitor, GcPid, long_gc, Info}</span> is sent to <span class="code">MonitorPid</span>. <span class="code">GcPid</span> is the pid that was garbage collected and <span class="code">Info</span> is a list of two-element tuples describing the result of the garbage collection. One of the tuples is <span class="code">{timeout, GcTime}</span> where <span class="code">GcTime</span> is the actual time for the garbage collection in milliseconds. The other tuples are tagged with <span class="code">heap_size</span>, <span class="code">heap_block_size</span>, <span class="code">stack_size</span>, <span class="code">mbuf_size</span>, <span class="code">old_heap_size</span>, and <span class="code">old_heap_block_size</span>. These tuples are explained in the documentation of the <span class="bold_code"><a href="#gc_start">gc_start</a></span> trace message (see <span class="bold_code"><a href="#trace-3">erlang:trace/3</a></span>). New tuples may be added, and the order of the tuples in the <span class="code">Info</span> list may be changed at any time without prior notice. </p> </dd> <dt><strong><span class="code">{large_heap, Size}</span></strong></dt> <dd> <p>If a garbage collection in the system results in the allocated size of a heap being at least <span class="code">Size</span> words, a message <span class="code">{monitor, GcPid, large_heap, Info}</span> is sent to <span class="code">MonitorPid</span>. <span class="code">GcPid</span> and <span class="code">Info</span> are the same as for <span class="code">long_gc</span> above, except that the tuple tagged with <span class="code">timeout</span> is not present. <strong>Note</strong>: As of erts version 5.6 the monitor message is sent if the sum of the sizes of all memory blocks allocated for all heap generations is equal to or larger than <span class="code">Size</span>. Previously the monitor message was sent if the memory block allocated for the youngest generation was equal to or larger than <span class="code">Size</span>. </p> </dd> <dt><strong><span class="code">busy_port</span></strong></dt> <dd> <p>If a process in the system gets suspended because it sends to a busy port, a message <span class="code">{monitor, SusPid, busy_port, Port}</span> is sent to <span class="code">MonitorPid</span>. <span class="code">SusPid</span> is the pid that got suspended when sending to <span class="code">Port</span>.</p> </dd> <dt><strong><span class="code">busy_dist_port</span></strong></dt> <dd> <p>If a process in the system gets suspended because it sends to a process on a remote node whose inter-node communication was handled by a busy port, a message <span class="code">{monitor, SusPid, busy_dist_port, Port}</span> is sent to <span class="code">MonitorPid</span>. <span class="code">SusPid</span> is the pid that got suspended when sending through the inter-node communication port <span class="code">Port</span>.</p> </dd> </dl> <p>Returns the previous system monitor settings just like <span class="bold_code"><a href="#system_monitor-0">erlang:system_monitor/0</a></span>.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>If a monitoring process gets so large that it itself starts to cause system monitor messages when garbage collecting, the messages will enlarge the process's message queue and probably make the problem worse.</p> <p>Keep the monitoring process neat and do not set the system monitor limits too tight.</p> </p></div> </div> <p>Failure: <span class="code">badarg</span> if <span class="code">MonitorPid</span> does not exist.</p> </p></div> <p><a name="system_profile-0"><span class="bold_code">erlang:system_profile() -> ProfilerSettings</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ProfilerSettings -> {ProfilerPid, Options} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> ProfilerPid = pid() | port()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Option = runnable_procs | runnable_ports | scheduler | exclusive</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the current system profiling settings set by <span class="bold_code"><a href="#system_profile-2">erlang:system_profile/2</a></span> as <span class="code">{ProfilerPid, Options}</span>, or <span class="code">undefined</span> if there are no settings. The order of the options may be different from the one that was set.</p> </p></div> <p><a name="system_profile-2"><span class="bold_code">erlang:system_profile(ProfilerPid, Options) -> ProfilerSettings</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ProfilerSettings -> {ProfilerPid, Options} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> ProfilerPid = pid() | port()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Options = [Option]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Option = runnable_procs | runnable_ports | scheduler | exclusive</span><br> </div> </div> <div class="REFBODY"><p> <p>Sets system profiler options. <span class="code">ProfilerPid</span> is a local pid or port that will receive profiling messages. The receiver is excluded from all profiling. The second argument is a list of profiling options:</p> <dl> <dt><strong><span class="code">runnable_procs</span></strong></dt> <dd> <p>If a process is put into or removed from the run queue a message, <span class="code">{profile, Pid, State, Mfa, Ts}</span>, is sent to <span class="code">ProfilerPid</span>. Running processes that is reinserted into the run queue after having been preemptively scheduled out will not trigger this message. </p> </dd> <dt><strong><span class="code">runnable_ports</span></strong></dt> <dd> <p>If a port is put into or removed from the run queue a message, <span class="code">{profile, Port, State, 0, Ts}</span>, is sent to <span class="code">ProfilerPid</span>. </p> </dd> <dt><strong><span class="code">scheduler</span></strong></dt> <dd> <p>If a scheduler is put to sleep or awoken a message, <span class="code">{profile, scheduler, Id, State, NoScheds, Ts}</span>, is sent to <span class="code">ProfilerPid</span>. </p> </dd> <dt><strong><span class="code">exclusive</span></strong></dt> <dd> <p> If a synchronous call to a port from a process is done, the calling process is considered not runnable during the call runtime to the port. The calling process is notified as <span class="code">inactive</span> and subsequently <span class="code">active</span> when the port callback returns. </p> </dd> </dl> <div class="note"> <div class="label">Note</div> <div class="content"><p><p><span class="code">erlang:system_profile</span> is considered experimental and its behaviour may change in the future.</p> </p></div> </div> </p></div> <p><a name="term_to_binary-1"><span class="bold_code">term_to_binary(Term) -> ext_binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a binary data object which is the result of encoding <span class="code">Term</span> according to the Erlang external term format.</p> <p>This can be used for a variety of purposes, for example writing a term to a file in an efficient way, or sending an Erlang term to some type of communications channel not supported by distributed Erlang.</p> <p>See also <span class="bold_code"><a href="#binary_to_term-1">binary_to_term/1</a></span>.</p> </p></div> <p><a name="term_to_binary-2"><span class="bold_code">term_to_binary(Term, [Option]) -> ext_binary()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Term = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Option = compressed | {compressed,Level} | {minor_version,Version}</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a binary data object which is the result of encoding <span class="code">Term</span> according to the Erlang external term format.</p> <p>If the option <span class="code">compressed</span> is provided, the external term format will be compressed. The compressed format is automatically recognized by <span class="code">binary_to_term/1</span> in R7B and later.</p> <p>It is also possible to specify a compression level by giving the option <span class="code">{compressed,Level}</span>, where <span class="code">Level</span> is an integer from 0 through 9. <span class="code">0</span> means that no compression will be done (it is the same as not giving any <span class="code">compressed</span> option); <span class="code">1</span> will take the least time but may not compress as well as the higher levels; <span class="code">9</span> will take the most time and may produce a smaller result. Note the "mays" in the preceding sentence; depending on the input term, level 9 compression may or may not produce a smaller result than level 1 compression.</p> <p>Currently, <span class="code">compressed</span> gives the same result as <span class="code">{compressed,6}</span>.</p> <p>The option <span class="code">{minor_version,Version}</span> can be use to control some details of the encoding. This option was introduced in R11B-4. Currently, the allowed values for <span class="code">Version</span> are <span class="code">0</span> and <span class="code">1</span>.</p> <p><span class="code">{minor_version,1}</span> forces any floats in the term to be encoded in a more space-efficient and exact way (namely in the 64-bit IEEE format, rather than converted to a textual representation). <span class="code">binary_to_term/1</span> in R11B-4 and later is able decode the new representation.</p> <p><span class="code">{minor_version,0}</span> is currently the default, meaning that floats will be encoded using a textual representation; this option is useful if you want to ensure that releases prior to R11B-4 can decode resulting binary.</p> <p>See also <span class="bold_code"><a href="#binary_to_term-1">binary_to_term/1</a></span>.</p> </p></div> <p><a name="throw-1"><span class="bold_code">throw(Any)</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Any = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>A non-local return from a function. If evaluated within a <span class="code">catch</span>, <span class="code">catch</span> will return the value <span class="code">Any</span>.</p> <div class="example"><pre> > <span class="bold_code">catch throw({hello, there}).</span> {hello,there}</pre></div> <p>Failure: <span class="code">nocatch</span> if not evaluated within a catch.</p> </p></div> <p><a name="time-0"><span class="bold_code">time() -> {Hour, Minute, Second}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Hour = Minute = Second = integer() >= 0</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the current time as <span class="code">{Hour, Minute, Second}</span>.</p> <p>The time zone and daylight saving time correction depend on the underlying OS.</p> <div class="example"><pre> > <span class="bold_code">time().</span> {9,42,44}</pre></div> </p></div> <p><a name="tl-1"><span class="bold_code">tl(List1) -> List2</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">List1 = List2 = [term()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the tail of <span class="code">List1</span>, that is, the list minus the first element.</p> <div class="example"><pre> > <span class="bold_code">tl([geesties, guilies, beasties]).</span> [guilies, beasties]</pre></div> <p>Allowed in guard tests.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">List</span> is the empty list [].</p> </p></div> <p><a name="trace-3"><span class="bold_code">erlang:trace(PidSpec, How, FlagList) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">PidSpec = pid() | existing | new | all</span><br> </div> <div class="REFTYPES"> <span class="bold_code">How = boolean()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">FlagList = [Flag]</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Flag -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Turns on (if <span class="code">How == true</span>) or off (if <span class="code">How == false</span>) the trace flags in <span class="code">FlagList</span> for the process or processes represented by <span class="code">PidSpec</span>.</p> <p><span class="code">PidSpec</span> is either a pid for a local process, or one of the following atoms:</p> <dl> <dt><strong><span class="code">existing</span></strong></dt> <dd> <p>All processes currently existing.</p> </dd> <dt><strong><span class="code">new</span></strong></dt> <dd> <p>All processes that will be created in the future.</p> </dd> <dt><strong><span class="code">all</span></strong></dt> <dd> <p>All currently existing processes and all processes that will be created in the future.</p> </dd> </dl> <p><span class="code">FlagList</span> can contain any number of the following flags (the "message tags" refers to the list of messages following below):</p> <dl> <dt><strong><span class="code">all</span></strong></dt> <dd> <p>Set all trace flags except <span class="code">{tracer, Tracer}</span> and <span class="code">cpu_timestamp</span> that are in their nature different than the others.</p> </dd> <dt><strong><span class="code">send</span></strong></dt> <dd> <p>Trace sending of messages.</p> <p>Message tags: <span class="code">send</span>, <span class="code">send_to_non_existing_process</span>.</p> </dd> <dt><strong><span class="code">'receive'</span></strong></dt> <dd> <p>Trace receiving of messages.</p> <p>Message tags: <span class="code">'receive'</span>.</p> </dd> <dt><strong><span class="code">procs</span></strong></dt> <dd> <p>Trace process related events.</p> <p>Message tags: <span class="code">spawn</span>, <span class="code">exit</span>, <span class="code">register</span>, <span class="code">unregister</span>, <span class="code">link</span>, <span class="code">unlink</span>, <span class="code">getting_linked</span>, <span class="code">getting_unlinked</span>.</p> </dd> <dt><strong><span class="code">call</span></strong></dt> <dd> <p>Trace certain function calls. Specify which function calls to trace by calling <span class="bold_code"><a href="#trace_pattern-3">erlang:trace_pattern/3</a></span>.</p> <p>Message tags: <span class="code">call</span>, <span class="code">return_from</span>.</p> </dd> <dt><strong><span class="code">silent</span></strong></dt> <dd> <p>Used in conjunction with the <span class="code">call</span> trace flag. The <span class="code">call</span>, <span class="code">return_from</span> and <span class="code">return_to</span> trace messages are inhibited if this flag is set, but if there are match specs they are executed as normal.</p> <p>Silent mode is inhibited by executing <span class="code">erlang:trace(_, false, [silent|_])</span>, or by a match spec executing the <span class="code">{silent, false}</span> function.</p> <p>The <span class="code">silent</span> trace flag facilitates setting up a trace on many or even all processes in the system. Then the interesting trace can be activated and deactivated using the <span class="code">{silent,Bool}</span> match spec function, giving a high degree of control of which functions with which arguments that triggers the trace.</p> <p>Message tags: <span class="code">call</span>, <span class="code">return_from</span>, <span class="code">return_to</span>. Or rather, the absence of.</p> </dd> <dt><strong><span class="code">return_to</span></strong></dt> <dd> <p>Used in conjunction with the <span class="code">call</span> trace flag. Trace the actual return from a traced function back to its caller. Only works for functions traced with the <span class="code">local</span> option to <span class="bold_code"><a href="#trace_pattern-3">erlang:trace_pattern/3</a></span>.</p> <p>The semantics is that a trace message is sent when a call traced function actually returns, that is, when a chain of tail recursive calls is ended. There will be only one trace message sent per chain of tail recursive calls, why the properties of tail recursiveness for function calls are kept while tracing with this flag. Using <span class="code">call</span> and <span class="code">return_to</span> trace together makes it possible to know exactly in which function a process executes at any time.</p> <p>To get trace messages containing return values from functions, use the <span class="code">{return_trace}</span> match_spec action instead.</p> <p>Message tags: <span class="code">return_to</span>.</p> </dd> <dt><strong><span class="code">running</span></strong></dt> <dd> <p>Trace scheduling of processes.</p> <p>Message tags: <span class="code">in</span>, and <span class="code">out</span>.</p> </dd> <dt><strong><span class="code">exiting</span></strong></dt> <dd> <p>Trace scheduling of an exiting processes.</p> <p>Message tags: <span class="code">in_exiting</span>, <span class="code">out_exiting</span>, and <span class="code">out_exited</span>.</p> </dd> <dt><strong><span class="code">garbage_collection</span></strong></dt> <dd> <p>Trace garbage collections of processes.</p> <p>Message tags: <span class="code">gc_start</span>, <span class="code">gc_end</span>.</p> </dd> <dt><strong><span class="code">timestamp</span></strong></dt> <dd> <p>Include a time stamp in all trace messages. The time stamp (Ts) is of the same form as returned by <span class="code">erlang:now()</span>.</p> </dd> <dt><strong><span class="code">cpu_timestamp</span></strong></dt> <dd> <p>A global trace flag for the Erlang node that makes all trace timestamps be in CPU time, not wallclock. It is only allowed with <span class="code">PidSpec==all</span>. If the host machine operating system does not support high resolution CPU time measurements, <span class="code">trace/3</span> exits with <span class="code">badarg</span>.</p> </dd> <dt><strong><span class="code">arity</span></strong></dt> <dd> <p>Used in conjunction with the <span class="code">call</span> trace flag. <span class="code">{M, F, Arity}</span> will be specified instead of <span class="code">{M, F, Args}</span> in call trace messages.</p> </dd> <dt><strong><span class="code">set_on_spawn</span></strong></dt> <dd> <p>Makes any process created by a traced process inherit its trace flags, including the <span class="code">set_on_spawn</span> flag.</p> </dd> <dt><strong><span class="code">set_on_first_spawn</span></strong></dt> <dd> <p>Makes the first process created by a traced process inherit its trace flags, excluding the <span class="code">set_on_first_spawn</span> flag.</p> </dd> <dt><strong><span class="code">set_on_link</span></strong></dt> <dd> <p>Makes any process linked by a traced process inherit its trace flags, including the <span class="code">set_on_link</span> flag.</p> </dd> <dt><strong><span class="code">set_on_first_link</span></strong></dt> <dd> <p>Makes the first process linked to by a traced process inherit its trace flags, excluding the <span class="code">set_on_first_link</span> flag.</p> </dd> <dt><strong><span class="code">{tracer, Tracer}</span></strong></dt> <dd> <p>Specify where to send the trace messages. <span class="code">Tracer</span> must be the pid of a local process or the port identifier of a local port. If this flag is not given, trace messages will be sent to the process that called <span class="code">erlang:trace/3</span>.</p> </dd> </dl> <p>The effect of combining <span class="code">set_on_first_link</span> with <span class="code">set_on_link</span> is the same as having <span class="code">set_on_first_link</span> alone. Likewise for <span class="code">set_on_spawn</span> and <span class="code">set_on_first_spawn</span>.</p> <p>If the <span class="code">timestamp</span> flag is not given, the tracing process will receive the trace messages described below. <span class="code">Pid</span> is the pid of the traced process in which the traced event has occurred. The third element of the tuple is the message tag.</p> <p>If the <span class="code">timestamp</span> flag is given, the first element of the tuple will be <span class="code">trace_ts</span> instead and the timestamp is added last in the tuple.</p> <dl> <dt><strong><span class="code">{trace, Pid, 'receive', Msg}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> receives the message <span class="code">Msg</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, send, Msg, To}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> sends the message <span class="code">Msg</span> to the process <span class="code">To</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, send_to_non_existing_process, Msg, To}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> sends the message <span class="code">Msg</span> to the non-existing process <span class="code">To</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, call, {M, F, Args}}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> calls a traced function. The return values of calls are never supplied, only the call and its arguments.</p> <p>Note that the trace flag <span class="code">arity</span> can be used to change the contents of this message, so that <span class="code">Arity</span> is specified instead of <span class="code">Args</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, return_to, {M, F, Arity}}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> returns <strong>to</strong> the specified function. This trace message is sent if both the <span class="code">call</span> and the <span class="code">return_to</span> flags are set, and the function is set to be traced on <strong>local</strong> function calls. The message is only sent when returning from a chain of tail recursive function calls where at least one call generated a <span class="code">call</span> trace message (that is, the functions match specification matched and <span class="code">{message, false}</span> was not an action).</p> </dd> <dt><strong><span class="code">{trace, Pid, return_from, {M, F, Arity}, ReturnValue}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> returns <strong>from</strong> the specified function. This trace message is sent if the <span class="code">call</span> flag is set, and the function has a match specification with a <span class="code">return_trace</span> or <span class="code">exception_trace</span> action.</p> </dd> <dt><strong><span class="code">{trace, Pid, exception_from, {M, F, Arity}, {Class, Value}}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> exits <strong>from</strong> the specified function due to an exception. This trace message is sent if the <span class="code">call</span> flag is set, and the function has a match specification with an <span class="code">exception_trace</span> action.</p> </dd> <dt><strong><span class="code">{trace, Pid, spawn, Pid2, {M, F, Args}}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> spawns a new process <span class="code">Pid2</span> with the specified function call as entry point.</p> <p>Note that <span class="code">Args</span> is supposed to be the argument list, but may be any term in the case of an erroneous spawn.</p> </dd> <dt><strong><span class="code">{trace, Pid, exit, Reason}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> exits with reason <span class="code">Reason</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, link, Pid2}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> links to a process <span class="code">Pid2</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, unlink, Pid2}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> removes the link from a process <span class="code">Pid2</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, getting_linked, Pid2}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> gets linked to a process <span class="code">Pid2</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, getting_unlinked, Pid2}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> gets unlinked from a process <span class="code">Pid2</span>.</p> </dd> <dt><strong><span class="code">{trace, Pid, register, RegName}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> gets the name <span class="code">RegName</span> registered.</p> </dd> <dt><strong><span class="code">{trace, Pid, unregister, RegName}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> gets the name <span class="code">RegName</span> unregistered. Note that this is done automatically when a registered process exits.</p> </dd> <dt><strong><span class="code">{trace, Pid, in, {M, F, Arity} | 0}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> is scheduled to run. The process will run in function <span class="code">{M, F, Arity}</span>. On some rare occasions the current function cannot be determined, then the last element <span class="code">Arity</span> is 0.</p> </dd> <dt><strong><span class="code">{trace, Pid, out, {M, F, Arity} | 0}</span></strong></dt> <dd> <p>When <span class="code">Pid</span> is scheduled out. The process was running in function {M, F, Arity}. On some rare occasions the current function cannot be determined, then the last element <span class="code">Arity</span> is 0.</p> </dd> <dt><strong><a name="gc_start"><span class="code">{trace, Pid, gc_start, Info}</span></a></strong></dt> <dd> <p>Sent when garbage collection is about to be started. <span class="code">Info</span> is a list of two-element tuples, where the first element is a key, and the second is the value. You should not depend on the tuples have any defined order. Currently, the following keys are defined:</p> <dl> <dt><strong><span class="code">heap_size</span></strong></dt> <dd>The size of the used part of the heap.</dd> <dt><strong><span class="code">heap_block_size</span></strong></dt> <dd>The size of the memory block used for storing the heap and the stack.</dd> <dt><strong><span class="code">old_heap_size</span></strong></dt> <dd>The size of the used part of the old heap.</dd> <dt><strong><span class="code">old_heap_block_size</span></strong></dt> <dd>The size of the memory block used for storing the old heap.</dd> <dt><strong><span class="code">stack_size</span></strong></dt> <dd>The actual size of the stack.</dd> <dt><strong><span class="code">recent_size</span></strong></dt> <dd>The size of the data that survived the previous garbage collection.</dd> <dt><strong><span class="code">mbuf_size</span></strong></dt> <dd>The combined size of message buffers associated with the process.</dd> <dt><strong><span class="code">bin_vheap_size</span></strong></dt> <dd>The total size of unique off-heap binaries referenced from the process heap.</dd> <dt><strong><span class="code">bin_vheap_block_size</span></strong></dt> <dd>The total size of binaries, in words, allowed in the virtual heap in the process before doing a garbage collection. </dd> <dt><strong><span class="code">bin_old_vheap_size</span></strong></dt> <dd>The total size of unique off-heap binaries referenced from the process old heap.</dd> <dt><strong><span class="code">bin_vheap_block_size</span></strong></dt> <dd>The total size of binaries, in words, allowed in the virtual old heap in the process before doing a garbage collection. </dd> </dl> <p>All sizes are in words.</p> </dd> <dt><strong><span class="code">{trace, Pid, gc_end, Info}</span></strong></dt> <dd> <p>Sent when garbage collection is finished. <span class="code">Info</span> contains the same kind of list as in the <span class="code">gc_start</span> message, but the sizes reflect the new sizes after garbage collection.</p> </dd> </dl> <p>If the tracing process dies, the flags will be silently removed.</p> <p>Only one process can trace a particular process. For this reason, attempts to trace an already traced process will fail.</p> <p>Returns: A number indicating the number of processes that matched <span class="code">PidSpec</span>. If <span class="code">PidSpec</span> is a pid, the return value will be <span class="code">1</span>. If <span class="code">PidSpec</span> is <span class="code">all</span> or <span class="code">existing</span> the return value will be the number of processes running, excluding tracer processes. If <span class="code">PidSpec</span> is <span class="code">new</span>, the return value will be <span class="code">0</span>.</p> <p>Failure: If specified arguments are not supported. For example <span class="code">cpu_timestamp</span> is not supported on all platforms.</p> </p></div> <p><a name="trace_delivered-1"><span class="bold_code">erlang:trace_delivered(Tracee) -> Ref</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Tracee = pid() | all</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Ref = reference()</span><br> </div> </div> <div class="REFBODY"><p> <p>The delivery of trace messages is dislocated on the time-line compared to other events in the system. If you know that the <span class="code">Tracee</span> has passed some specific point in its execution, and you want to know when at least all trace messages corresponding to events up to this point have reached the tracer you can use <span class="code">erlang:trace_delivered(Tracee)</span>. A <span class="code">{trace_delivered, Tracee, Ref}</span> message is sent to the caller of <span class="code">erlang:trace_delivered(Tracee)</span> when it is guaranteed that all trace messages have been delivered to the tracer up to the point that the <span class="code">Tracee</span> had reached at the time of the call to <span class="code">erlang:trace_delivered(Tracee)</span>.</p> <p>Note that the <span class="code">trace_delivered</span> message does <strong>not</strong> imply that trace messages have been delivered; instead, it implies that all trace messages that <strong>should</strong> be delivered have been delivered. It is not an error if <span class="code">Tracee</span> isn't, and hasn't been traced by someone, but if this is the case, <strong>no</strong> trace messages will have been delivered when the <span class="code">trace_delivered</span> message arrives.</p> <p>Note that <span class="code">Tracee</span> has to refer to a process currently, or previously existing on the same node as the caller of <span class="code">erlang:trace_delivered(Tracee)</span> resides on. The special <span class="code">Tracee</span> atom <span class="code">all</span> denotes all processes that currently are traced in the node.</p> <p>An example: Process <span class="code">A</span> is tracee, port <span class="code">B</span> is tracer, and process <span class="code">C</span> is the port owner of <span class="code">B</span>. <span class="code">C</span> wants to close <span class="code">B</span> when <span class="code">A</span> exits. <span class="code">C</span> can ensure that the trace isn't truncated by calling <span class="code">erlang:trace_delivered(A)</span> when <span class="code">A</span> exits and wait for the <span class="code">{trace_delivered, A, Ref}</span> message before closing <span class="code">B</span>.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">Tracee</span> does not refer to a process (dead or alive) on the same node as the caller of <span class="code">erlang:trace_delivered(Tracee)</span> resides on.</p> </p></div> <p><a name="trace_info-2"><span class="bold_code">erlang:trace_info(PidOrFunc, Item) -> Res</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">PidOrFunc = pid() | new | {Module, Function, Arity} | on_load</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Module = Function = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code"> Arity = arity()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Item, Res -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns trace information about a process or function.</p> <p>To get information about a process, <span class="code">PidOrFunc</span> should be a pid or the atom <span class="code">new</span>. The atom <span class="code">new</span> means that the default trace state for processes to be created will be returned. <span class="code">Item</span> must have one of the following values:</p> <dl> <dt><strong><span class="code">flags</span></strong></dt> <dd> <p>Return a list of atoms indicating what kind of traces is enabled for the process. The list will be empty if no traces are enabled, and one or more of the followings atoms if traces are enabled: <span class="code">send</span>, <span class="code">'receive'</span>, <span class="code">set_on_spawn</span>, <span class="code">call</span>, <span class="code">return_to</span>, <span class="code">procs</span>, <span class="code">set_on_first_spawn</span>, <span class="code">set_on_link</span>, <span class="code">running</span>, <span class="code">garbage_collection</span>, <span class="code">timestamp</span>, and <span class="code">arity</span>. The order is arbitrary.</p> </dd> <dt><strong><span class="code">tracer</span></strong></dt> <dd> <p>Return the identifier for process or port tracing this process. If this process is not being traced, the return value will be <span class="code">[]</span>.</p> </dd> </dl> <p>To get information about a function, <span class="code">PidOrFunc</span> should be a three-element tuple: <span class="code">{Module, Function, Arity}</span> or the atom <span class="code">on_load</span>. No wildcards are allowed. Returns <span class="code">undefined</span> if the function does not exist or <span class="code">false</span> if the function is not traced at all. <span class="code">Item</span> must have one of the following values:</p> <dl> <dt><strong><span class="code">traced</span></strong></dt> <dd> <p>Return <span class="code">global</span> if this function is traced on global function calls, <span class="code">local</span> if this function is traced on local function calls (i.e local and global function calls), and <span class="code">false</span> if neither local nor global function calls are traced.</p> </dd> <dt><strong><span class="code">match_spec</span></strong></dt> <dd> <p>Return the match specification for this function, if it has one. If the function is locally or globally traced but has no match specification defined, the returned value is <span class="code">[]</span>.</p> </dd> <dt><strong><span class="code">meta</span></strong></dt> <dd> <p>Return the meta trace tracer process or port for this function, if it has one. If the function is not meta traced the returned value is <span class="code">false</span>, and if the function is meta traced but has once detected that the tracer proc is invalid, the returned value is [].</p> </dd> <dt><strong><span class="code">meta_match_spec</span></strong></dt> <dd> <p>Return the meta trace match specification for this function, if it has one. If the function is meta traced but has no match specification defined, the returned value is <span class="code">[]</span>.</p> </dd> <dt><strong><span class="code">call_count</span></strong></dt> <dd> <p>Return the call count value for this function or <span class="code">true</span> for the pseudo function <span class="code">on_load</span> if call count tracing is active. Return <span class="code">false</span> otherwise. See also <span class="bold_code"><a href="#trace_pattern-3">erlang:trace_pattern/3</a></span>.</p> </dd> <dt><strong><span class="code">call_time</span></strong></dt> <dd> <p>Return the call time values for this function or <span class="code">true</span> for the pseudo function <span class="code">on_load</span> if call time tracing is active. Returns <span class="code">false</span> otherwise. The call time values returned, <span class="code">[{Pid, Count, S, Us}]</span>, is a list of each process that has executed the function and its specific counters. See also <span class="bold_code"><a href="#trace_pattern-3">erlang:trace_pattern/3</a></span>.</p> </dd> <dt><strong><span class="code">all</span></strong></dt> <dd> <p>Return a list containing the <span class="code">{Item, Value}</span> tuples for all other items, or return <span class="code">false</span> if no tracing is active for this function.</p> </dd> </dl> <p>The actual return value will be <span class="code">{Item, Value}</span>, where <span class="code">Value</span> is the requested information as described above. If a pid for a dead process was given, or the name of a non-existing function, <span class="code">Value</span> will be <span class="code">undefined</span>.</p> <p>If <span class="code">PidOrFunc</span> is the <span class="code">on_load</span>, the information returned refers to the default value for code that will be loaded.</p> </p></div> <p><a name="trace_pattern-2"><span class="bold_code">erlang:trace_pattern(MFA, MatchSpec) -> integer() >= 0</span></a><br></p> <div class="REFBODY"><p> <p>The same as <span class="bold_code"><a href="#trace_pattern-3">erlang:trace_pattern(MFA, MatchSpec, [])</a></span>, retained for backward compatibility.</p> </p></div> <p><a name="trace_pattern-3"><span class="bold_code">erlang:trace_pattern(MFA, MatchSpec, FlagList) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MFA, MatchSpec, FlagList -- see below</span><br> </div> </div> <div class="REFBODY"><p> <p>This BIF is used to enable or disable call tracing for exported functions. It must be combined with <span class="bold_code"><a href="#trace-3">erlang:trace/3</a></span> to set the <span class="code">call</span> trace flag for one or more processes.</p> <p>Conceptually, call tracing works like this: Inside the Erlang virtual machine there is a set of processes to be traced and a set of functions to be traced. Tracing will be enabled on the intersection of the set. That is, if a process included in the traced process set calls a function included in the traced function set, the trace action will be taken. Otherwise, nothing will happen.</p> <p>Use <span class="bold_code"><a href="#trace-3">erlang:trace/3</a></span> to add or remove one or more processes to the set of traced processes. Use <span class="code">erlang:trace_pattern/2</span> to add or remove exported functions to the set of traced functions.</p> <p>The <span class="code">erlang:trace_pattern/3</span> BIF can also add match specifications to an exported function. A match specification comprises a pattern that the arguments to the function must match, a guard expression which must evaluate to <span class="code">true</span> and an action to be performed. The default action is to send a trace message. If the pattern does not match or the guard fails, the action will not be executed.</p> <p>The <span class="code">MFA</span> argument should be a tuple like <span class="code">{Module, Function, Arity}</span> or the atom <span class="code">on_load</span> (described below). It can be the module, function, and arity for an exported function (or a BIF in any module). The <span class="code">'_'</span> atom can be used to mean any of that kind. Wildcards can be used in any of the following ways:</p> <dl> <dt><strong><span class="code">{Module,Function,'_'}</span></strong></dt> <dd> <p>All exported functions of any arity named <span class="code">Function</span> in module <span class="code">Module</span>.</p> </dd> <dt><strong><span class="code">{Module,'_','_'}</span></strong></dt> <dd> <p>All exported functions in module <span class="code">Module</span>.</p> </dd> <dt><strong><span class="code">{'_','_','_'}</span></strong></dt> <dd> <p>All exported functions in all loaded modules.</p> </dd> </dl> <p>Other combinations, such as <span class="code">{Module,'_',Arity}</span>, are not allowed. Local functions will match wildcards only if the <span class="code">local</span> option is in the <span class="code">FlagList</span>.</p> <p>If the <span class="code">MFA</span> argument is the atom <span class="code">on_load</span>, the match specification and flag list will be used on all modules that are newly loaded.</p> <p>The <span class="code">MatchSpec</span> argument can take any of the following forms:</p> <dl> <dt><strong><span class="code">false</span></strong></dt> <dd> <p>Disable tracing for the matching function(s). Any match specification will be removed.</p> </dd> <dt><strong><span class="code">true</span></strong></dt> <dd> <p>Enable tracing for the matching function(s).</p> </dd> <dt><strong><span class="code">MatchSpecList</span></strong></dt> <dd> <p>A list of match specifications. An empty list is equivalent to <span class="code">true</span>. See the ERTS User's Guide for a description of match specifications.</p> </dd> <dt><strong><span class="code">restart</span></strong></dt> <dd> <p>For the <span class="code">FlagList</span> option <span class="code">call_count</span> and <span class="code">call_time</span>: restart the existing counters. The behaviour is undefined for other <span class="code">FlagList</span> options.</p> </dd> <dt><strong><span class="code">pause</span></strong></dt> <dd> <p>For the <span class="code">FlagList</span> option <span class="code">call_count</span> and <span class="code">call_time</span>: pause the existing counters. The behaviour is undefined for other <span class="code">FlagList</span> options.</p> </dd> </dl> <p>The <span class="code">FlagList</span> parameter is a list of options. The following options are allowed:</p> <dl> <dt><strong><span class="code">global</span></strong></dt> <dd> <p>Turn on or off call tracing for global function calls (that is, calls specifying the module explicitly). Only exported functions will match and only global calls will generate trace messages. This is the default.</p> </dd> <dt><strong><span class="code">local</span></strong></dt> <dd> <p>Turn on or off call tracing for all types of function calls. Trace messages will be sent whenever any of the specified functions are called, regardless of how they are called. If the <span class="code">return_to</span> flag is set for the process, a <span class="code">return_to</span> message will also be sent when this function returns to its caller.</p> </dd> <dt><strong><span class="code">meta | {meta, Pid}</span></strong></dt> <dd> <p>Turn on or off meta tracing for all types of function calls. Trace messages will be sent to the tracer process or port <span class="code">Pid</span> whenever any of the specified functions are called, regardless of how they are called. If no <span class="code">Pid</span> is specified, <span class="code">self()</span> is used as a default tracer process.</p> <p>Meta tracing traces all processes and does not care about the process trace flags set by <span class="code">trace/3</span>, the trace flags are instead fixed to <span class="code">[call, timestamp]</span>.</p> <p>The match spec function <span class="code">{return_trace}</span> works with meta trace and send its trace message to the same tracer process.</p> </dd> <dt><strong><span class="code">call_count</span></strong></dt> <dd> <p>Starts (<span class="code">MatchSpec == true</span>) or stops (<span class="code">MatchSpec == false</span>) call count tracing for all types of function calls. For every function a counter is incremented when the function is called, in any process. No process trace flags need to be activated.</p> <p>If call count tracing is started while already running, the count is restarted from zero. Running counters can be paused with <span class="code">MatchSpec == pause</span>. Paused and running counters can be restarted from zero with <span class="code">MatchSpec == restart</span>.</p> <p>The counter value can be read with <span class="bold_code"><a href="#trace_info-2">erlang:trace_info/2</a></span>.</p> </dd> <dt><strong><span class="code">call_time</span></strong></dt> <dd> <p>Starts (<span class="code">MatchSpec == true</span>) or stops (<span class="code">MatchSpec == false</span>) call time tracing for all types of function calls. For every function a counter is incremented when the function is called. Time spent in the function is accumulated in two other counters, seconds and micro-seconds. The counters are stored for each call traced process.</p> <p>If call time tracing is started while already running, the count and time is restarted from zero. Running counters can be paused with <span class="code">MatchSpec == pause</span>. Paused and running counters can be restarted from zero with <span class="code">MatchSpec == restart</span>.</p> <p>The counter value can be read with <span class="bold_code"><a href="#trace_info-2">erlang:trace_info/2</a></span>.</p> </dd> </dl> <p>The <span class="code">global</span> and <span class="code">local</span> options are mutually exclusive and <span class="code">global</span> is the default (if no options are specified). The <span class="code">call_count</span> and <span class="code">meta</span> options perform a kind of local tracing, and can also not be combined with <span class="code">global</span>. A function can be either globally or locally traced. If global tracing is specified for a specified set of functions; local, meta, call time and call count tracing for the matching set of local functions will be disabled, and vice versa.</p> <p>When disabling trace, the option must match the type of trace that is set on the function, so that local tracing must be disabled with the <span class="code">local</span> option and global tracing with the <span class="code">global</span> option (or no option at all), and so forth.</p> <p>There is no way to directly change part of a match specification list. If a function has a match specification, you can replace it with a completely new one. If you need to change an existing match specification, use the <span class="bold_code"><a href="#trace_info-2">erlang:trace_info/2</a></span> BIF to retrieve the existing match specification.</p> <p>Returns the number of exported functions that matched the <span class="code">MFA</span> argument. This will be zero if none matched at all.</p> </p></div> <p><a name="trunc-1"><span class="bold_code">trunc(Number) -> integer()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Number = number()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer by the truncating <span class="code">Number</span>.</p> <div class="example"><pre> > <span class="bold_code">trunc(5.5).</span> 5</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="tuple_size-1"><span class="bold_code">tuple_size(Tuple) -> integer() >= 0</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Tuple = tuple()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns an integer which is the number of elements in <span class="code">Tuple</span>.</p> <div class="example"><pre> > <span class="bold_code">tuple_size({morni, mulle, bwange}).</span> 3</pre></div> <p>Allowed in guard tests.</p> </p></div> <p><a name="tuple_to_list-1"><span class="bold_code">tuple_to_list(Tuple) -> [term()]</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Tuple = tuple()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list which corresponds to <span class="code">Tuple</span>. <span class="code">Tuple</span> may contain any Erlang terms.</p> <div class="example"><pre> > <span class="bold_code">tuple_to_list({share, {'Ericsson_B', 163}}).</span> [share,{'Ericsson_B',163}]</pre></div> </p></div> <p><a name="universaltime-0"><span class="bold_code">erlang:universaltime() -> DateTime</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">DateTime = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-datetime');">calendar:datetime()</a></span></span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the current date and time according to Universal Time Coordinated (UTC), also called GMT, in the form <span class="code">{{Year, Month, Day}, {Hour, Minute, Second}}</span> if supported by the underlying operating system. If not, <span class="code">erlang:universaltime()</span> is equivalent to <span class="code">erlang:localtime()</span>.</p> <div class="example"><pre> > <span class="bold_code">erlang:universaltime().</span> {{1996,11,6},{14,18,43}}</pre></div> </p></div> <p><a name="universaltime_to_localtime-1"><span class="bold_code">erlang:universaltime_to_localtime({Date1, Time1}) -> {Date2, Time2}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Date1 = Date2 = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-date');">calendar:date()</a></span></span><br> </div> <div class="REFTYPES"> <span class="bold_code">Time1 = Time2 = <span class="bold_code"><a href="javascript:erlhref('../../../doc/../','stdlib','calendar.html#type-time');">calendar:time()</a></span></span><br> </div> </div> <div class="REFBODY"><p> <p>Converts Universal Time Coordinated (UTC) date and time to local date and time, if this is supported by the underlying OS. Otherwise, no conversion is done, and <span class="code">{Date1, Time1}</span> is returned.</p> <div class="example"><pre> > <span class="bold_code">erlang:universaltime_to_localtime({{1996,11,6},{14,18,43}}).</span> {{1996,11,7},{15,18,43}}</pre></div> <p>Failure: <span class="code">badarg</span> if <span class="code">Date1</span> or <span class="code">Time1</span> do not denote a valid date or time.</p> </p></div> <p><a name="unlink-1"><span class="bold_code">unlink(Id) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Id = pid() | port()</span><br> </div> </div> <div class="REFBODY"><p> <p>Removes the link, if there is one, between the calling process and the process or port referred to by <span class="code">Id</span>.</p> <p>Returns <span class="code">true</span> and does not fail, even if there is no link to <span class="code">Id</span>, or if <span class="code">Id</span> does not exist.</p> <p>Once <span class="code">unlink(Id)</span> has returned it is guaranteed that the link between the caller and the entity referred to by <span class="code">Id</span> has no effect on the caller in the future (unless the link is setup again). If caller is trapping exits, an <span class="code">{'EXIT', Id, _}</span> message due to the link might have been placed in the caller's message queue prior to the call, though. Note, the <span class="code">{'EXIT', Id, _}</span> message can be the result of the link, but can also be the result of <span class="code">Id</span> calling <span class="code">exit/2</span>. Therefore, it <strong>may</strong> be appropriate to cleanup the message queue when trapping exits after the call to <span class="code">unlink(Id)</span>, as follow:</p> <div class="example"><pre> unlink(Id), receive {'EXIT', Id, _} -> true after 0 -> true end</pre></div> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>Prior to OTP release R11B (erts version 5.5) <span class="code">unlink/1</span> behaved completely asynchronous, i.e., the link was active until the "unlink signal" reached the linked entity. This had one undesirable effect, though. You could never know when you were guaranteed <strong>not</strong> to be effected by the link.</p> <p>Current behavior can be viewed as two combined operations: asynchronously send an "unlink signal" to the linked entity and ignore any future results of the link.</p> </p></div> </div> </p></div> <p><a name="unregister-1"><span class="bold_code">unregister(RegName) -> true</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">RegName = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>Removes the registered name <span class="code">RegName</span>, associated with a pid or a port identifier.</p> <div class="example"><pre> > <span class="bold_code">unregister(db).</span> true</pre></div> <p>Users are advised not to unregister system processes.</p> <p>Failure: <span class="code">badarg</span> if <span class="code">RegName</span> is not a registered name.</p> </p></div> <p><a name="whereis-1"><span class="bold_code">whereis(RegName) -> pid() | port() | undefined</span></a><br></p> <div class="REFBODY"><p> <p>Returns the pid or port identifier with the registered name <span class="code">RegName</span>. Returns <span class="code">undefined</span> if the name is not registered.</p> <div class="example"><pre> > <span class="bold_code">whereis(db).</span> <0.43.0></pre></div> </p></div> <p><a name="yield-0"></a><span class="bold_code">erlang:yield() -> true</span><br></p> <div class="REFBODY"><p> <p>Voluntarily let other processes (if any) get a chance to execute. Using <span class="code">erlang:yield()</span> is similar to <span class="code">receive after 1 -> ok end</span>, except that <span class="code">yield()</span> is faster.</p> <div class="warning"> <div class="label">Warning</div> <div class="content"><p><p>There is seldom or never any need to use this BIF, especially in the SMP-emulator as other processes will have a chance to run in another scheduler thread anyway. Using this BIF without a thorough grasp of how the scheduler works may cause performance degradation.</p></p></div> </div> </p></div> </div> <div class="footer"> <hr> <p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>