1erlang(3)                  Erlang Module Definition                  erlang(3)
2
3
4

NAME

6       erlang - The Erlang BIFs.
7

DESCRIPTION

9       By convention, most Built-In Functions (BIFs) are included in this mod‐
10       ule. Some of the BIFs are viewed more or less as  part  of  the  Erlang
11       programming  language  and are auto-imported. Thus, it is not necessary
12       to specify the module name. For example, the calls atom_to_list(erlang)
13       and erlang:atom_to_list(erlang) are identical.
14
15       Auto-imported  BIFs  are listed without module prefix. BIFs listed with
16       module prefix are not auto-imported.
17
18       BIFs can fail for various reasons. All BIFs fail with reason badarg  if
19       they  are called with arguments of an incorrect type. The other reasons
20       are described in the description of each individual BIF.
21
22       Some BIFs can be used in guard tests and are marked  with  "Allowed  in
23       guard tests".
24

DATA TYPES

26       ext_binary() = binary()
27
28              A  binary data object, structured according to the Erlang exter‐
29              nal term format.
30
31       ext_iovec() = iovec()
32
33              A term of type  iovec(),  structured  according  to  the  Erlang
34              external term format.
35
36       iovec() = [binary()]
37
38              A list of binaries. This datatype is useful to use together with
39              enif_inspect_iovec.
40
41       message_queue_data() = off_heap | on_heap
42
43              See process_flag(message_queue_data, MQD).
44
45       timestamp() =
46           {MegaSecs :: integer() >= 0,
47            Secs :: integer() >= 0,
48            MicroSecs :: integer() >= 0}
49
50              See erlang:timestamp/0.
51
52       time_unit() =
53           integer() >= 1 |
54           second | millisecond | microsecond | nanosecond | native |
55           perf_counter |
56           deprecated_time_unit()
57
58              Supported time unit representations:
59
60                PartsPerSecond :: integer() >= 1:
61                  Time unit expressed in parts per second. That is,  the  time
62                  unit equals 1/PartsPerSecond second.
63
64                second:
65                  Symbolic  representation of the time unit represented by the
66                  integer 1.
67
68                millisecond:
69                  Symbolic representation of the time unit represented by  the
70                  integer 1000.
71
72                microsecond:
73                  Symbolic  representation of the time unit represented by the
74                  integer 1000_000.
75
76                nanosecond:
77                  Symbolic representation of the time unit represented by  the
78                  integer 1000_000_000.
79
80                native:
81                  Symbolic  representation of the native time unit used by the
82                  Erlang runtime system.
83
84                  The native time unit is determined at runtime system  start,
85                  and remains the same until the runtime system terminates. If
86                  a runtime system is stopped and then started again (even  on
87                  the  same  machine), the native time unit of the new runtime
88                  system instance can differ from the native time unit of  the
89                  old runtime system instance.
90
91                  One  can  get  an  approximation  of the native time unit by
92                  calling  erlang:convert_time_unit(1,  second,  native).  The
93                  result equals the number of whole native time units per sec‐
94                  ond. If the number of native time units per second does  not
95                  add up to a whole number, the result is rounded downwards.
96
97            Note:
98                The  value  of  the native time unit gives you more or less no
99                information about the quality of time values. It sets a  limit
100                for the  resolution and for the  precision of time values, but
101                it gives no information about the  accuracy  of  time  values.
102                The  resolution  of the native time unit and the resolution of
103                time values can differ significantly.
104
105
106                perf_counter:
107                  Symbolic representation of the performance counter time unit
108                  used by the Erlang runtime system.
109
110                  The  perf_counter  time unit behaves much in the same way as
111                  the native time unit. That is, it can differ between runtime
112                  restarts.    To    get    values    of   this   type,   call
113                  os:perf_counter/0.
114
115                deprecated_time_unit():
116                  Deprecated symbolic representations kept for  backwards-com‐
117                  patibility.
118
119              The  time_unit/0  type  can  be extended. To convert time values
120              between time units, use erlang:convert_time_unit/3.
121
122       deprecated_time_unit() =
123           seconds | milli_seconds | micro_seconds | nano_seconds
124
125              The time_unit() type also consist of  the  following  deprecated
126              symbolic time units:
127
128                seconds:
129                  Same as second.
130
131                milli_seconds:
132                  Same as millisecond.
133
134                micro_seconds:
135                  Same as microsecond.
136
137                nano_seconds:
138                  Same as nanosecond.
139
140       dist_handle()
141
142              An opaque handle identifing a distribution channel.
143
144       nif_resource()
145
146              An opaque handle identifing a NIF resource object .
147
148       spawn_opt_option() =
149           link | monitor |
150           {priority, Level :: priority_level()} |
151           {fullsweep_after, Number :: integer() >= 0} |
152           {min_heap_size, Size :: integer() >= 0} |
153           {min_bin_vheap_size, VSize :: integer() >= 0} |
154           {max_heap_size, Size :: max_heap_size()} |
155           {message_queue_data, MQD :: message_queue_data()}
156
157              Options for spawn_opt().
158
159       priority_level() = low | normal | high | max
160
161              Process priority level. For more info see process_flag(priority,
162              Level)
163
164       max_heap_size() =
165           integer() >= 0 |
166           #{size => integer() >= 0,
167             kill => boolean(),
168             error_logger => boolean()}
169
170              Process  max  heap  size  configuration.  For  more   info   see
171              process_flag(max_heap_size, MaxHeapSize)
172
173       message_queue_data() = off_heap | on_heap
174
175              Process  message queue data configuration. For more information,
176              see process_flag(message_queue_data, MQD)
177

EXPORTS

179       abs(Float) -> float()
180
181       abs(Int) -> integer() >= 0
182
183              Types:
184
185                 Int = integer()
186
187              Returns an integer or float that is  the  arithmetical  absolute
188              value of Float or Int, for example:
189
190              > abs(-3.33).
191              3.33
192              > abs(-3).
193              3
194
195              Allowed in guard tests.
196
197       erlang:adler32(Data) -> integer() >= 0
198
199              Types:
200
201                 Data = iodata()
202
203              Computes and returns the adler32 checksum for Data.
204
205       erlang:adler32(OldAdler, Data) -> integer() >= 0
206
207              Types:
208
209                 OldAdler = integer() >= 0
210                 Data = iodata()
211
212              Continues computing the adler32 checksum by combining the previ‐
213              ous checksum, OldAdler, with the checksum of Data.
214
215              The following code:
216
217              X = erlang:adler32(Data1),
218              Y = erlang:adler32(X,Data2).
219
220              assigns the same value to Y as this:
221
222              Y = erlang:adler32([Data1,Data2]).
223
224       erlang:adler32_combine(FirstAdler, SecondAdler, SecondSize) ->
225                                 integer() >= 0
226
227              Types:
228
229                 FirstAdler = SecondAdler = SecondSize = integer() >= 0
230
231              Combines two previously computed adler32 checksums. This  compu‐
232              tation  requires  the  size  of  the  data object for the second
233              checksum to be known.
234
235              The following code:
236
237              Y = erlang:adler32(Data1),
238              Z = erlang:adler32(Y,Data2).
239
240              assigns the same value to Z as this:
241
242              X = erlang:adler32(Data1),
243              Y = erlang:adler32(Data2),
244              Z = erlang:adler32_combine(X,Y,iolist_size(Data2)).
245
246       erlang:append_element(Tuple1, Term) -> Tuple2
247
248              Types:
249
250                 Tuple1 = Tuple2 = tuple()
251                 Term = term()
252
253              Returns a new tuple that has one element more than  Tuple1,  and
254              contains  the  elements  in  Tuple1 followed by Term as the last
255              element.          Semantically           equivalent           to
256              list_to_tuple(tuple_to_list(Tuple1) ++ [Term]), but much faster.
257              Example:
258
259              > erlang:append_element({one, two}, three).
260              {one,two,three}
261
262       apply(Fun, Args) -> term()
263
264              Types:
265
266                 Fun = function()
267                 Args = [term()]
268
269              Calls a fun, passing the elements in Args as arguments.
270
271              If the number of elements in the arguments are known at  compile
272              time, the call is better written as Fun(Arg1, Arg2, ... ArgN).
273
274          Warning:
275              Earlier,  Fun  could  also  be  specified as {Module, Function},
276              equivalent to apply(Module, Function, Args). This use is  depre‐
277              cated and will stop working in a future release.
278
279
280       apply(Module, Function, Args) -> term()
281
282              Types:
283
284                 Module = module()
285                 Function = atom()
286                 Args = [term()]
287
288              Returns  the  result of applying Function in Module to Args. The
289              applied function must be exported from Module. The arity of  the
290              function is the length of Args. Example:
291
292              > apply(lists, reverse, [[a, b, c]]).
293              [c,b,a]
294              > apply(erlang, atom_to_list, ['Erlang']).
295              "Erlang"
296
297              If  the  number of arguments are known at compile time, the call
298              is better written as Module:Function(Arg1, Arg2, ..., ArgN).
299
300              Failure: error_handler:undefined_function/3  is  called  if  the
301              applied function is not exported. The error handler can be rede‐
302              fined (see process_flag/2). If error_handler is undefined, or if
303              the user has redefined the default error_handler so the replace‐
304              ment module is undefined, an error with reason undef  is  gener‐
305              ated.
306
307       atom_to_binary(Atom) -> binary()
308
309              Types:
310
311                 Atom = atom()
312
313              The same as atom_to_binary(Atom, utf8).
314
315       atom_to_binary(Atom, Encoding) -> binary()
316
317              Types:
318
319                 Atom = atom()
320                 Encoding = latin1 | unicode | utf8
321
322              Returns  a  binary  corresponding  to the text representation of
323              Atom. If Encoding is latin1, one byte exists for each  character
324              in  the text representation. If Encoding is utf8 or unicode, the
325              characters are encoded using UTF-8 where characters may  require
326              multiple bytes.
327
328          Note:
329              As  from  Erlang/OTP 20, atoms can contain any Unicode character
330              and atom_to_binary(Atom, latin1) may fail if the text  represen‐
331              tation for Atom contains a Unicode character > 255.
332
333
334              Example:
335
336              > atom_to_binary('Erlang', latin1).
337              <<"Erlang">>
338
339       atom_to_list(Atom) -> string()
340
341              Types:
342
343                 Atom = atom()
344
345              Returns  a  string  corresponding  to the text representation of
346              Atom, for example:
347
348              > atom_to_list('Erlang').
349              "Erlang"
350
351       binary_part(Subject, PosLen) -> binary()
352
353              Types:
354
355                 Subject = binary()
356                 PosLen = {Start :: integer() >= 0, Length :: integer()}
357
358              Extracts the part of the binary described by PosLen.
359
360              Negative length can be used to extract bytes at  the  end  of  a
361              binary, for example:
362
363              1> Bin = <<1,2,3,4,5,6,7,8,9,10>>.
364              2> binary_part(Bin,{byte_size(Bin), -5}).
365              <<6,7,8,9,10>>
366
367              Failure:  badarg  if  PosLen  in  any way references outside the
368              binary.
369
370              Start is zero-based, that is:
371
372              1> Bin = <<1,2,3>>
373              2> binary_part(Bin,{0,2}).
374              <<1,2>>
375
376              For details about the PosLen semantics, see binary(3).
377
378              Allowed in guard tests.
379
380       binary_part(Subject, Start, Length) -> binary()
381
382              Types:
383
384                 Subject = binary()
385                 Start = integer() >= 0
386                 Length = integer()
387
388              The same as binary_part(Subject, {Start, Length}).
389
390              Allowed in guard tests.
391
392       binary_to_atom(Binary) -> atom()
393
394              Types:
395
396                 Binary = binary()
397
398              The same as binary_to_atom(Binary, utf8).
399
400       binary_to_atom(Binary, Encoding) -> atom()
401
402              Types:
403
404                 Binary = binary()
405                 Encoding = latin1 | unicode | utf8
406
407              Returns the atom whose text representation is Binary. If  Encod‐
408              ing  is  utf8  or  unicode,  the binary must contain valid UTF-8
409              sequences.
410
411          Note:
412              As from Erlang/OTP 20, binary_to_atom(Binary, utf8)  is  capable
413              of  encoding  any Unicode character. Earlier versions would fail
414              if the binary contained  Unicode  characters  >  255.  For  more
415              information  about  Unicode  support  in  atoms, see the note on
416              UTF-8 encoded atoms in section "External  Term  Format"  in  the
417              User's Guide.
418
419
420              Examples:
421
422              > binary_to_atom(<<"Erlang">>, latin1).
423              > binary_to_atom(<<1024/utf8>>, utf8).
424
425       binary_to_existing_atom(Binary) -> atom()
426
427              Types:
428
429                 Binary = binary()
430
431              The same as binary_to_existing_atom (Binary, utf8).
432
433       binary_to_existing_atom(Binary, Encoding) -> atom()
434
435              Types:
436
437                 Binary = binary()
438                 Encoding = latin1 | unicode | utf8
439
440              As binary_to_atom/2, but the atom must exist.
441
442              Failure: badarg if the atom does not exist.
443
444          Note:
445              Note that the compiler may optimize away atoms. For example, the
446              compiler will rewrite atom_to_list(some_atom) to "some_atom". If
447              that expression is the only mention of the atom some_atom in the
448              containing module, the atom will not be created when the  module
449              is   loaded,   and   a   subsequent   call  to  binary_to_exist‐
450              ing_atom(<<"some_atom">>, utf8) will fail.
451
452
453       binary_to_float(Binary) -> float()
454
455              Types:
456
457                 Binary = binary()
458
459              Returns the float whose text representation is Binary, for exam‐
460              ple:
461
462              > binary_to_float(<<"2.2017764e+0">>).
463              2.2017764
464
465              Failure:  badarg  if  Binary  contains a bad representation of a
466              float.
467
468       binary_to_integer(Binary) -> integer()
469
470              Types:
471
472                 Binary = binary()
473
474              Returns an integer whose  text  representation  is  Binary,  for
475              example:
476
477              > binary_to_integer(<<"123">>).
478              123
479
480              Failure:  badarg  if  Binary contains a bad representation of an
481              integer.
482
483       binary_to_integer(Binary, Base) -> integer()
484
485              Types:
486
487                 Binary = binary()
488                 Base = 2..36
489
490              Returns an integer whose text representation  in  base  Base  is
491              Binary, for example:
492
493              > binary_to_integer(<<"3FF">>, 16).
494              1023
495
496              Failure:  badarg  if  Binary contains a bad representation of an
497              integer.
498
499       binary_to_list(Binary) -> [byte()]
500
501              Types:
502
503                 Binary = binary()
504
505              Returns a list of integers corresponding to the bytes of Binary.
506
507       binary_to_list(Binary, Start, Stop) -> [byte()]
508
509              Types:
510
511                 Binary = binary()
512                 Start = Stop = integer() >= 1
513                   1..byte_size(Binary)
514
515              As binary_to_list/1, but returns a list of integers  correspond‐
516              ing to the bytes from position Start to position Stop in Binary.
517              The positions in the binary are numbered starting from 1.
518
519          Note:
520              The one-based indexing for binaries used  by  this  function  is
521              deprecated.  New  code  is to use binary:bin_to_list/3 in STDLIB
522              instead. All functions in module binary consistently  use  zero-
523              based indexing.
524
525
526       binary_to_term(Binary) -> term()
527
528              Types:
529
530                 Binary = ext_binary()
531
532              Returns  an  Erlang  term  that is the result of decoding binary
533              object Binary, which must be encoded according  to  the   Erlang
534              external term format.
535
536              > Bin = term_to_binary(hello).
537              <<131,100,0,5,104,101,108,108,111>>
538              > hello = binary_to_term(Bin).
539              hello
540
541
542          Warning:
543              When  decoding  binaries  from untrusted sources, consider using
544              binary_to_term/2 to prevent Denial of Service attacks.
545
546
547              See also term_to_binary/1 and binary_to_term/2.
548
549       binary_to_term(Binary, Opts) -> term() | {term(), Used}
550
551              Types:
552
553                 Binary = ext_binary()
554                 Opt = safe | used
555                 Opts = [Opt]
556                 Used = integer() >= 1
557
558              As binary_to_term/1, but takes these options:
559
560                safe:
561                  Use this option when receiving binaries  from  an  untrusted
562                  source.
563
564                  When  enabled, it prevents decoding data that can be used to
565                  attack the Erlang system. In the event of  receiving  unsafe
566                  data, decoding fails with a badarg error.
567
568                  This  prevents  creation  of new atoms directly, creation of
569                  new atoms indirectly (as they are embedded in certain struc‐
570                  tures,  such  as  process  identifiers, refs, and funs), and
571                  creation of new external function references. None of  those
572                  resources  are  garbage  collected, so unchecked creation of
573                  them can exhaust available memory.
574
575                > binary_to_term(<<131,100,0,5,"hello">>, [safe]).
576                ** exception error: bad argument
577                > hello.
578                hello
579                > binary_to_term(<<131,100,0,5,"hello">>, [safe]).
580                hello
581
582
583                used:
584                  Changes the return value to {Term, Used} where Used  is  the
585                  number of bytes actually read from Binary.
586
587                > Input = <<131,100,0,5,"hello","world">>.
588                <<131,100,0,5,104,101,108,108,111,119,111,114,108,100>>
589                > {Term, Used} = binary_to_term(Input, [used]).
590                {hello, 9}
591                > split_binary(Input, Used).
592                {<<131,100,0,5,104,101,108,108,111>>, <<"world">>}
593
594
595              Failure: badarg if safe is specified and unsafe data is decoded.
596
597              See  also term_to_binary/1, binary_to_term/1, and list_to_exist‐
598              ing_atom/1.
599
600       bit_size(Bitstring) -> integer() >= 0
601
602              Types:
603
604                 Bitstring = bitstring()
605
606              Returns an integer that is the size in bits  of  Bitstring,  for
607              example:
608
609              > bit_size(<<433:16,3:3>>).
610              19
611              > bit_size(<<1,2,3>>).
612              24
613
614              Allowed in guard tests.
615
616       bitstring_to_list(Bitstring) -> [byte() | bitstring()]
617
618              Types:
619
620                 Bitstring = bitstring()
621
622              Returns  a  list  of integers corresponding to the bytes of Bit‐
623              string. If the number of bits in the binary is not divisible  by
624              8,  the  last  element of the list is a bitstring containing the
625              remaining 1-7 bits.
626
627       erlang:bump_reductions(Reductions) -> true
628
629              Types:
630
631                 Reductions = integer() >= 1
632
633              This implementation-dependent function increments the  reduction
634              counter  for  the  calling  process.  In  the Beam emulator, the
635              reduction counter is normally incremented by one for each  func‐
636              tion  and  BIF call. A context switch is forced when the counter
637              reaches the maximum number of reductions  for  a  process  (2000
638              reductions in Erlang/OTP R12B).
639
640          Warning:
641              This  BIF can be removed in a future version of the Beam machine
642              without prior warning. It is unlikely to be implemented in other
643              Erlang implementations.
644
645
646       byte_size(Bitstring) -> integer() >= 0
647
648              Types:
649
650                 Bitstring = bitstring()
651
652              Returns an integer that is the number of bytes needed to contain
653              Bitstring. That is, if the number of bits in  Bitstring  is  not
654              divisible  by  8,  the  resulting number of bytes is rounded up.
655              Examples:
656
657              > byte_size(<<433:16,3:3>>).
658              3
659              > byte_size(<<1,2,3>>).
660              3
661
662              Allowed in guard tests.
663
664       erlang:cancel_timer(TimerRef) -> Result
665
666              Types:
667
668                 TimerRef = reference()
669                 Time = integer() >= 0
670                 Result = Time | false
671
672              Cancels a timer. The same as calling  erlang:cancel_timer(Timer‐
673              Ref, []).
674
675       erlang:cancel_timer(TimerRef, Options) -> Result | ok
676
677              Types:
678
679                 TimerRef = reference()
680                 Async = Info = boolean()
681                 Option = {async, Async} | {info, Info}
682                 Options = [Option]
683                 Time = integer() >= 0
684                 Result = Time | false
685
686              Cancels  a  timer that has been created by erlang:start_timer or
687              erlang:send_after.  TimerRef  identifies  the  timer,  and   was
688              returned by the BIF that created the timer.
689
690              Options:
691
692                {async, Async}:
693                  Asynchronous  request  for  cancellation.  Async defaults to
694                  false, which causes the cancellation to  be  performed  syn‐
695                  chronously.  When Async is set to true, the cancel operation
696                  is performed asynchronously. That is,  cancel_timer()  sends
697                  an  asynchronous  request for cancellation to the timer ser‐
698                  vice that manages the timer, and then returns ok.
699
700                {info, Info}:
701                  Requests information about the Result of  the  cancellation.
702                  Info defaults to true, which means the Result is given. When
703                  Info is set to false, no information about the result of the
704                  cancellation is given.
705
706                  * When  Async  is  false:  if  Info  is  true, the Result is
707                    returned  by  erlang:cancel_timer().   otherwise   ok   is
708                    returned.
709
710                  * When Async is true: if Info is true, a message on the form
711                    {cancel_timer, TimerRef, Result} is sent to the caller  of
712                    erlang:cancel_timer()  when the cancellation operation has
713                    been performed, otherwise no message is sent.
714
715              More Options may be added in the future.
716
717              If Result is an integer, it represents the time in  milliseconds
718              left until the canceled timer would have expired.
719
720              If  Result is false, a timer corresponding to TimerRef could not
721              be found. This can be either  because  the  timer  had  expired,
722              already  had  been  canceled,  or  because TimerRef never corre‐
723              sponded to a timer. Even if the timer had expired, it  does  not
724              tell  you if the time-out message has arrived at its destination
725              yet.
726
727          Note:
728              The timer service that manages the timer can be co-located  with
729              another scheduler than the scheduler that the calling process is
730              executing on. If so, communication with the timer service  takes
731              much  longer  time than if it is located locally. If the calling
732              process is in critical path, and can do other things while wait‐
733              ing  for  the  result of this operation, or is not interested in
734              the result of the operation, you  want  to  use  option  {async,
735              true}.  If  using  option  {async,  false},  the calling process
736              blocks until the operation has been performed.
737
738
739              See   also   erlang:send_after/4,   erlang:start_timer/4,    and
740              erlang:read_timer/2.
741
742       ceil(Number) -> integer()
743
744              Types:
745
746                 Number = number()
747
748              Returns the smallest integer not less than Number. For example:
749
750              > ceil(5.5).
751              6
752
753              Allowed in guard tests.
754
755       check_old_code(Module) -> boolean()
756
757              Types:
758
759                 Module = module()
760
761              Returns true if Module has old code, otherwise false.
762
763              See also code(3).
764
765       check_process_code(Pid, Module) -> CheckResult
766
767              Types:
768
769                 Pid = pid()
770                 Module = module()
771                 CheckResult = boolean()
772
773              The same as check_process_code(Pid, Module, []).
774
775       check_process_code(Pid, Module, OptionList) -> CheckResult | async
776
777              Types:
778
779                 Pid = pid()
780                 Module = module()
781                 RequestId = term()
782                 Option = {async, RequestId} | {allow_gc, boolean()}
783                 OptionList = [Option]
784                 CheckResult = boolean() | aborted
785
786              Checks  if the node local process identified by Pid executes old
787              code for Module.
788
789              Options:
790
791                {allow_gc, boolean()}:
792                  Determines if garbage collection is allowed when  performing
793                  the operation. If {allow_gc, false} is passed, and a garbage
794                  collection is needed to determine the result of  the  opera‐
795                  tion,  the operation is aborted (see information on CheckRe‐
796                  sult below). The default is  to  allow  garbage  collection,
797                  that is, {allow_gc, true}.
798
799                {async, RequestId}:
800                  The  function  check_process_code/3  returns the value async
801                  immediately after  the  request  has  been  sent.  When  the
802                  request  has  been  processed,  the process that called this
803                  function   is    passed    a    message    on    the    form
804                  {check_process_code, RequestId, CheckResult}.
805
806              If  Pid  equals self(), and no async option has been passed, the
807              operation is performed at once.  Otherwise  a  request  for  the
808              operation  is sent to the process identified by Pid, and is han‐
809              dled when appropriate. If no async option has been  passed,  the
810              caller   blocks  until  CheckResult  is  available  and  can  be
811              returned.
812
813              CheckResult informs about the result of the request as follows:
814
815                true:
816                  The process identified by Pid executes old code for  Module.
817                  That  is,  the current call of the process executes old code
818                  for this module, or the process has references to  old  code
819                  for  this  module,  or the process contains funs that refer‐
820                  ences old code for this module.
821
822                false:
823                  The process identified by Pid does not execute old code  for
824                  Module.
825
826                aborted:
827                  The  operation  was  aborted,  as  the  process needed to be
828                  garbage collected to determine the operation result, and the
829                  operation was requested by passing option {allow_gc, false}.
830
831          Note:
832              Up  until  ERTS  version  8.*,  the check process code operation
833              checks for all types of references to the  old  code.  That  is,
834              direct  references (e.g. return addresses on the process stack),
835              indirect references (funs in process context), and references to
836              literals in the code.
837
838              As  of  ERTS  version 9.0, the check process code operation only
839              checks for direct references to the  code.  Indirect  references
840              via  funs will be ignored. If such funs exist and are used after
841              a purge of the old code, an exception will be raised upon  usage
842              (same  as the case when the fun is received by the process after
843              the purge). Literals will be taken care of (copied) at  a  later
844              stage.  This behavior can as of ERTS version 8.1 be enabled when
845              building OTP, and will automatically be enabled if dirty  sched‐
846              uler support is enabled.
847
848
849              See also code(3).
850
851              Failures:
852
853                badarg:
854                  If Pid is not a node local process identifier.
855
856                badarg:
857                  If Module is not an atom.
858
859                badarg:
860                  If OptionList is an invalid list of options.
861
862       erlang:convert_time_unit(Time, FromUnit, ToUnit) -> ConvertedTime
863
864              Types:
865
866                 Time = ConvertedTime = integer()
867                 FromUnit = ToUnit = time_unit()
868
869              Converts the Time value of time unit FromUnit to the correspond‐
870              ing ConvertedTime value of  time  unit  ToUnit.  The  result  is
871              rounded using the floor function.
872
873          Warning:
874              You can lose accuracy and precision when converting between time
875              units. To minimize such loss, collect all data  at  native  time
876              unit and do the conversion on the end result.
877
878
879       erlang:crc32(Data) -> integer() >= 0
880
881              Types:
882
883                 Data = iodata()
884
885              Computes  and  returns the crc32 (IEEE 802.3 style) checksum for
886              Data.
887
888       erlang:crc32(OldCrc, Data) -> integer() >= 0
889
890              Types:
891
892                 OldCrc = integer() >= 0
893                 Data = iodata()
894
895              Continues computing the crc32 checksum by combining the previous
896              checksum, OldCrc, with the checksum of Data.
897
898              The following code:
899
900              X = erlang:crc32(Data1),
901              Y = erlang:crc32(X,Data2).
902
903              assigns the same value to Y as this:
904
905              Y = erlang:crc32([Data1,Data2]).
906
907       erlang:crc32_combine(FirstCrc, SecondCrc, SecondSize) ->
908                               integer() >= 0
909
910              Types:
911
912                 FirstCrc = SecondCrc = SecondSize = integer() >= 0
913
914              Combines  two previously computed crc32 checksums. This computa‐
915              tion requires the size of the data object for the second  check‐
916              sum to be known.
917
918              The following code:
919
920              Y = erlang:crc32(Data1),
921              Z = erlang:crc32(Y,Data2).
922
923              assigns the same value to Z as this:
924
925              X = erlang:crc32(Data1),
926              Y = erlang:crc32(Data2),
927              Z = erlang:crc32_combine(X,Y,iolist_size(Data2)).
928
929       date() -> Date
930
931              Types:
932
933                 Date = calendar:date()
934
935              Returns the current date as {Year, Month, Day}.
936
937              The  time zone and Daylight Saving Time correction depend on the
938              underlying OS. Example:
939
940              > date().
941              {1995,2,19}
942
943       erlang:decode_packet(Type, Bin, Options) ->
944                               {ok, Packet, Rest} |
945                               {more, Length} |
946                               {error, Reason}
947
948              Types:
949
950                 Type =
951                     raw | 0 | 1 | 2 | 4 | asn1 | cdr | sunrm | fcgi | tpkt |
952                     line | http | http_bin | httph | httph_bin
953                 Bin = binary()
954                 Options = [Opt]
955                 Opt =
956                     {packet_size, integer() >= 0} |
957                     {line_length, integer() >= 0}
958                 Packet = binary() | HttpPacket
959                 Rest = binary()
960                 Length = integer() >= 0 | undefined
961                 Reason = term()
962                 HttpPacket =
963                     HttpRequest | HttpResponse  |  HttpHeader  |  http_eoh  |
964                 HttpError
965                 HttpRequest  =  {http_request,  HttpMethod, HttpUri, HttpVer‐
966                 sion}
967                 HttpResponse =
968                     {http_response, HttpVersion, integer(), HttpString}
969                 HttpHeader =
970                     {http_header,
971                      integer(),
972                      HttpField,
973                      UnmodifiedField :: HttpString,
974                      Value :: HttpString}
975                 HttpError = {http_error, HttpString}
976                 HttpMethod =
977                     'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' |
978                     'TRACE' | HttpString
979                 HttpUri =
980                     '*' |
981                     {absoluteURI,
982                      http | https,
983                      Host :: HttpString,
984                      Port :: inet:port_number() | undefined,
985                      Path :: HttpString} |
986                     {scheme, Scheme :: HttpString, HttpString} |
987                     {abs_path, HttpString} |
988                     HttpString
989                 HttpVersion =
990                     {Major :: integer() >= 0, Minor :: integer() >= 0}
991                 HttpField =
992                     'Cache-Control' | 'Connection' | 'Date' | 'Pragma' |
993                     'Transfer-Encoding' | 'Upgrade' | 'Via' | 'Accept' |
994                     'Accept-Charset' | 'Accept-Encoding' |  'Accept-Language'
995                 |
996                     'Authorization' | 'From' | 'Host' | 'If-Modified-Since' |
997                     'If-Match' | 'If-None-Match' | 'If-Range' |
998                     'If-Unmodified-Since' | 'Max-Forwards' |
999                     'Proxy-Authorization'  |  'Range'  |  'Referer'  | 'User-
1000                 Agent' |
1001                     'Age' | 'Location' | 'Proxy-Authenticate' | 'Public' |
1002                     'Retry-After' | 'Server' | 'Vary' | 'Warning' |
1003                     'Www-Authenticate' | 'Allow' | 'Content-Base' |
1004                     'Content-Encoding'  |  'Content-Language'   |   'Content-
1005                 Length' |
1006                     'Content-Location' | 'Content-Md5' | 'Content-Range' |
1007                     'Content-Type' | 'Etag' | 'Expires' | 'Last-Modified' |
1008                     'Accept-Ranges' | 'Set-Cookie' | 'Set-Cookie2' |
1009                     'X-Forwarded-For' | 'Cookie' | 'Keep-Alive' |
1010                     'Proxy-Connection' | HttpString
1011                 HttpString = string() | binary()
1012
1013              Decodes  the  binary Bin according to the packet protocol speci‐
1014              fied by Type. Similar to the packet  handling  done  by  sockets
1015              with option {packet,Type}.
1016
1017              If an entire packet is contained in Bin, it is returned together
1018              with the remainder of the binary as {ok,Packet,Rest}.
1019
1020              If Bin does not contain  the  entire  packet,  {more,Length}  is
1021              returned.  Length  is  either  the  expected  total  size of the
1022              packet, or undefined if the expected  packet  size  is  unknown.
1023              decode_packet can then be called again with more data added.
1024
1025              If   the  packet  does  not  conform  to  the  protocol  format,
1026              {error,Reason} is returned.
1027
1028              Types:
1029
1030                raw | 0:
1031                  No packet handling is done. The entire  binary  is  returned
1032                  unless it is empty.
1033
1034                1 | 2 | 4:
1035                  Packets  consist  of a header specifying the number of bytes
1036                  in the packet, followed by that number of bytes. The  length
1037                  of  the  header can be one, two, or four bytes; the order of
1038                  the bytes is big-endian. The header is stripped off when the
1039                  packet is returned.
1040
1041                line:
1042                  A  packet  is a line-terminated by a delimiter byte, default
1043                  is the latin-1 newline  character.  The  delimiter  byte  is
1044                  included  in  the  returned packet unless the line was trun‐
1045                  cated according to option line_length.
1046
1047                asn1 | cdr | sunrm | fcgi | tpkt:
1048                  The header is not stripped off.
1049
1050                  The meanings of the packet types are as follows:
1051
1052                  asn1 - ASN.1 BER:
1053
1054
1055                  sunrm - Sun's RPC encoding:
1056
1057
1058                  cdr - CORBA (GIOP 1.1):
1059
1060
1061                  fcgi - Fast CGI:
1062
1063
1064                  tpkt - TPKT format [RFC1006]:
1065
1066
1067                http | httph | http_bin | httph_bin:
1068                  The Hypertext Transfer Protocol. The  packets  are  returned
1069                  with the format according to HttpPacket described earlier. A
1070                  packet is either a request, a response, a header, or an  end
1071                  of header mark. Invalid lines are returned as HttpError.
1072
1073                  Recognized request methods and header fields are returned as
1074                  atoms. Others are returned as strings. Strings  of  unrecog‐
1075                  nized  header fields are formatted with only capital letters
1076                  first and after hyphen characters,  for  example,  "Sec-Web‐
1077                  socket-Key". Header field names are also returned in Unmodi‐
1078                  fiedField as strings, without any conversion or formatting.
1079
1080                  The protocol type http is only to be used for the first line
1081                  when an HttpRequest or an HttpResponse is expected. The fol‐
1082                  lowing calls are to  use  httph  to  get  HttpHeaders  until
1083                  http_eoh is returned, which marks the end of the headers and
1084                  the beginning of any following message body.
1085
1086                  The variants http_bin and httph_bin  return  strings  (Http‐
1087                  String) as binaries instead of lists.
1088
1089              Options:
1090
1091                {packet_size, integer() >= 0}:
1092                  Sets  the  maximum  allowed  size of the packet body. If the
1093                  packet header indicates that the length  of  the  packet  is
1094                  longer  than  the maximum allowed length, the packet is con‐
1095                  sidered invalid. Defaults to 0, which means no size limit.
1096
1097                {line_length, integer() >= 0}:
1098                  For packet type line, lines longer than the indicated length
1099                  are truncated.
1100
1101                  Option  line_length also applies to http* packet types as an
1102                  alias for option packet_size if packet_size  itself  is  not
1103                  set. This use is only intended for backward compatibility.
1104
1105                {line_delimiter, 0 =< byte() =< 255}:
1106                  For  packet  type line, sets the delimiting byte. Default is
1107                  the latin-1 character $\n.
1108
1109              Examples:
1110
1111              > erlang:decode_packet(1,<<3,"abcd">>,[]).
1112              {ok,<<"abc">>,<<"d">>}
1113              > erlang:decode_packet(1,<<5,"abcd">>,[]).
1114              {more,6}
1115
1116       erlang:delete_element(Index, Tuple1) -> Tuple2
1117
1118              Types:
1119
1120                 Index = integer() >= 1
1121                   1..tuple_size(Tuple1)
1122                 Tuple1 = Tuple2 = tuple()
1123
1124              Returns a new tuple with element at  Index  removed  from  tuple
1125              Tuple1, for example:
1126
1127              > erlang:delete_element(2, {one, two, three}).
1128              {one,three}
1129
1130       delete_module(Module) -> true | undefined
1131
1132              Types:
1133
1134                 Module = module()
1135
1136              Makes  the  current  code for Module become old code and deletes
1137              all references for this module from the  export  table.  Returns
1138              undefined if the module does not exist, otherwise true.
1139
1140          Warning:
1141              This  BIF  is  intended for the code server (see code(3)) and is
1142              not to be used elsewhere.
1143
1144
1145              Failure: badarg if there already is an old version of Module.
1146
1147       demonitor(MonitorRef) -> true
1148
1149              Types:
1150
1151                 MonitorRef = reference()
1152
1153              If MonitorRef is a reference that the calling  process  obtained
1154              by calling monitor/2, this monitoring is turned off. If the mon‐
1155              itoring is already turned off, nothing happens.
1156
1157              Once demonitor(MonitorRef) has returned, it is  guaranteed  that
1158              no  {'DOWN',  MonitorRef, _, _, _} message, because of the moni‐
1159              tor, will be placed in the caller message queue in  the  future.
1160              However,  a  {'DOWN', MonitorRef, _, _, _} message can have been
1161              placed in the caller message queue before the call. It is there‐
1162              fore  usually advisable to remove such a 'DOWN' message from the
1163              message queue after monitoring has been stopped. demonitor(Moni‐
1164              torRef, [flush]) can be used instead of demonitor(MonitorRef) if
1165              this cleanup is wanted.
1166
1167          Note:
1168              Before Erlang/OTP R11B (ERTS 5.5) demonitor/1 behaved completely
1169              asynchronously,  that  is,  the  monitor  was  active  until the
1170              "demonitor signal" reached the monitored entity.  This  had  one
1171              undesirable  effect.  You could never know when you were guaran‐
1172              teed not to receive a DOWN message because of the monitor.
1173
1174              The current behavior can be viewed as two  combined  operations:
1175              asynchronously send a "demonitor signal" to the monitored entity
1176              and ignore any future results of the monitor.
1177
1178
1179              Failure: It is an error if MonitorRef  refers  to  a  monitoring
1180              started  by  another  process.  Not  all such cases are cheap to
1181              check. If checking is cheap, the call  fails  with  badarg,  for
1182              example if MonitorRef is a remote reference.
1183
1184       demonitor(MonitorRef, OptionList) -> boolean()
1185
1186              Types:
1187
1188                 MonitorRef = reference()
1189                 OptionList = [Option]
1190                 Option = flush | info
1191
1192              The returned value is true unless info is part of OptionList.
1193
1194              demonitor(MonitorRef,  [])  is  equivalent to demonitor(Monitor‐
1195              Ref).
1196
1197              Options:
1198
1199                flush:
1200                  Removes (one) {_, MonitorRef, _, _, _} message, if there  is
1201                  one, from the caller message queue after monitoring has been
1202                  stopped.
1203
1204                  Calling demonitor(MonitorRef, [flush]) is equivalent to  the
1205                  following, but more efficient:
1206
1207                demonitor(MonitorRef),
1208                receive
1209                    {_, MonitorRef, _, _, _} ->
1210                        true
1211                after 0 ->
1212                        true
1213                end
1214
1215                info:
1216                  The returned value is one of the following:
1217
1218                  true:
1219                    The monitor was found and removed. In this case, no 'DOWN'
1220                    message corresponding to this monitor has  been  delivered
1221                    and will not be delivered.
1222
1223                  false:
1224                    The  monitor  was not found and could not be removed. This
1225                    probably because someone already has placed a 'DOWN'  mes‐
1226                    sage  corresponding  to this monitor in the caller message
1227                    queue.
1228
1229                  If option info is  combined  with  option  flush,  false  is
1230                  returned if a flush was needed, otherwise true.
1231
1232          Note:
1233              More options can be added in a future release.
1234
1235
1236              Failures:
1237
1238                badarg:
1239                  If OptionList is not a list.
1240
1241                badarg:
1242                  If Option is an invalid option.
1243
1244                badarg:
1245                  The same failure as for demonitor/1.
1246
1247       disconnect_node(Node) -> boolean() | ignored
1248
1249              Types:
1250
1251                 Node = node()
1252
1253              Forces  the  disconnection  of  a node. This appears to the node
1254              Node as if the local node has crashed. This BIF is  mainly  used
1255              in the Erlang network authentication protocols.
1256
1257              Returns  true if disconnection succeeds, otherwise false. If the
1258              local node is not alive, ignored is returned.
1259
1260       erlang:display(Term) -> true
1261
1262              Types:
1263
1264                 Term = term()
1265
1266              Prints a text representation of Term on the standard output.
1267
1268          Warning:
1269              This BIF is intended for debugging only.
1270
1271
1272       erlang:dist_ctrl_get_data(DHandle) -> {Size, Data} | Data | none
1273
1274              Types:
1275
1276                 Size = integer() >= 0
1277                 DHandle = dist_handle()
1278                 Data = iovec()
1279
1280              Get distribution channel data from the local node that is to  be
1281              passed  to  the remote node. The distribution channel is identi‐
1282              fied by DHandle. If no data  is  available,  the  atom  none  is
1283              returned.  One can request to be informed by a message when more
1284              data is available by calling erlang:dist_ctrl_get_data_notifica‐
1285              tion(DHandle).
1286
1287              The  returned value when there are data available depends on the
1288              value of the get_size  option  configured  on  the  distribution
1289              channel identified by DHandle. For more information see the doc‐
1290              umentation    of     the     get_size     option     for     the
1291              erlang:dist_ctrl_set_opt/3 function.
1292
1293          Note:
1294              Only  the  process registered as distribution controller for the
1295              distribution channel identified by DHandle is  allowed  to  call
1296              this function.
1297
1298
1299              This function is used when implementing an alternative distribu‐
1300              tion carrier using processes as distribution controllers.  DHan‐
1301              dle  is  retrived  via  the  callback f_handshake_complete. More
1302              information can be found in the  documentation  of  ERTS  User's
1303              Guide  ➜  How to implement an Alternative Carrier for the Erlang
1304              Distribution ➜ Distribution Module.
1305
1306       erlang:dist_ctrl_get_opt(DHandle, Opt :: get_size) -> Value
1307
1308              Types:
1309
1310                 DHandle = dist_handle()
1311                 Value = boolean()
1312
1313              Returns the value of the get_size  option  on  the  distribution
1314              channel identified by DHandle. For more information see the doc‐
1315              umentation    of     the     get_size     option     for     the
1316              erlang:dist_ctrl_set_opt/3 function.
1317
1318          Note:
1319              Only  the  process registered as distribution controller for the
1320              distribution channel identified by DHandle is  allowed  to  call
1321              this function.
1322
1323
1324              This function is used when implementing an alternative distribu‐
1325              tion carrier using processes as distribution controllers.  DHan‐
1326              dle  is  retrived  via  the  callback f_handshake_complete. More
1327              information can be found in the  documentation  of  ERTS  User's
1328              Guide  ➜  How to implement an Alternative Carrier for the Erlang
1329              Distribution ➜ Distribution Module.
1330
1331       erlang:dist_ctrl_get_data_notification(DHandle) -> ok
1332
1333              Types:
1334
1335                 DHandle = dist_handle()
1336
1337              Request notification when more data is available to fetch  using
1338              erlang:dist_ctrl_get_data(DHandle)  for the distribution channel
1339              identified by DHandle. When more data  is  present,  the  caller
1340              will  be  sent  the message dist_data. Once a dist_data messages
1341              has been sent, no more dist_data messages will be sent until the
1342              dist_ctrl_get_data_notification/1   function   has  been  called
1343              again.
1344
1345          Note:
1346              Only the process registered as distribution controller  for  the
1347              distribution  channel  identified  by DHandle is allowed to call
1348              this function.
1349
1350
1351              This function is used when implementing an alternative distribu‐
1352              tion  carrier using processes as distribution controllers. DHan‐
1353              dle is retrived  via  the  callback  f_handshake_complete.  More
1354              information  can  be  found  in the documentation of ERTS User's
1355              Guide ➜ How to implement an Alternative Carrier for  the  Erlang
1356              Distribution ➜ Distribution Module.
1357
1358       erlang:dist_ctrl_input_handler(DHandle, InputHandler) -> ok
1359
1360              Types:
1361
1362                 DHandle = dist_handle()
1363                 InputHandler = pid()
1364
1365              Register an alternate input handler process for the distribution
1366              channel identified by  DHandle.  Once  this  function  has  been
1367              called,  InputHandler  is  the  only  process  allowed  to  call
1368              erlang:dist_ctrl_put_data(DHandle, Data) with the DHandle  iden‐
1369              tifing this distribution channel.
1370
1371          Note:
1372              Only  the  process registered as distribution controller for the
1373              distribution channel identified by DHandle is  allowed  to  call
1374              this function.
1375
1376
1377              This function is used when implementing an alternative distribu‐
1378              tion carrier using processes as distribution controllers.  DHan‐
1379              dle  is  retrived  via  the  callback f_handshake_complete. More
1380              information can be found in the  documentation  of  ERTS  User's
1381              Guide  ➜  How to implement an Alternative Carrier for the Erlang
1382              Distribution ➜ Distribution Module.
1383
1384       erlang:dist_ctrl_put_data(DHandle, Data) -> ok
1385
1386              Types:
1387
1388                 DHandle = dist_handle()
1389                 Data = iodata()
1390
1391              Deliver distribution channel data from  a  remote  node  to  the
1392              local node.
1393
1394          Note:
1395              Only  the  process registered as distribution controller for the
1396              distribution channel identified by DHandle is  allowed  to  call
1397              this function unless an alternate input handler process has been
1398              registered     using     erlang:dist_ctrl_input_handler(DHandle,
1399              InputHandler).  If  an  alternate  input handler has been regis‐
1400              tered, only the registered input handler process is  allowed  to
1401              call this function.
1402
1403
1404              This function is used when implementing an alternative distribu‐
1405              tion carrier using processes as distribution controllers.  DHan‐
1406              dle  is  retrived  via  the  callback f_handshake_complete. More
1407              information can be found in the  documentation  of  ERTS  User's
1408              Guide  ➜  How to implement an Alternative Carrier for the Erlang
1409              Distribution ➜ Distribution Module.
1410
1411       erlang:dist_ctrl_set_opt(DHandle, Opt :: get_size, Value) ->
1412                                   OldValue
1413
1414              Types:
1415
1416                 DHandle = dist_handle()
1417                 Value = OldValue = boolean()
1418
1419              Sets the value of the get_size option on the distribution  chan‐
1420              nel identified by DHandle. This option controls the return value
1421              of calls  to  erlang:dist_ctrl_get_data(DHandle)  where  DHandle
1422              equals  DHandle used when setting this option. When the get_size
1423              option is:
1424
1425                false:
1426                   and there  are  distribution  data  available,  a  call  to
1427                  erlang:dist_ctrl_get_data(DHandle)  will just return Data to
1428                  pass over the channel. This is  the  default  value  of  the
1429                  get_size option.
1430
1431                true:
1432                   and  there  are  distribution  data  available,  a  call to
1433                  erlang:dist_ctrl_get_data(DHandle) will return Data to  pass
1434                  over  the channel as well as the Size of Data in bytes. This
1435                  is returned as a tuple on the form {Size, Data}.
1436
1437              All options are set to default when a channel is closed.
1438
1439          Note:
1440              Only the process registered as distribution controller  for  the
1441              distribution  channel  identified  by DHandle is allowed to call
1442              this function.
1443
1444
1445              This function is used when implementing an alternative distribu‐
1446              tion  carrier using processes as distribution controllers. DHan‐
1447              dle is retrived  via  the  callback  f_handshake_complete.  More
1448              information  can  be  found  in the documentation of ERTS User's
1449              Guide ➜ How to implement an Alternative Carrier for  the  Erlang
1450              Distribution ➜ Distribution Module.
1451
1452       element(N, Tuple) -> term()
1453
1454              Types:
1455
1456                 N = integer() >= 1
1457                   1..tuple_size(Tuple)
1458                 Tuple = tuple()
1459
1460              Returns  the  Nth element (numbering from 1) of Tuple, for exam‐
1461              ple:
1462
1463              > element(2, {a, b, c}).
1464              b
1465
1466              Allowed in guard tests.
1467
1468       erase() -> [{Key, Val}]
1469
1470              Types:
1471
1472                 Key = Val = term()
1473
1474              Returns the process dictionary and deletes it, for example:
1475
1476              > put(key1, {1, 2, 3}),
1477              put(key2, [a, b, c]),
1478              erase().
1479              [{key1,{1,2,3}},{key2,[a,b,c]}]
1480
1481       erase(Key) -> Val | undefined
1482
1483              Types:
1484
1485                 Key = Val = term()
1486
1487              Returns the value Val associated with Key and  deletes  it  from
1488              the process dictionary. Returns undefined if no value is associ‐
1489              ated with Key. Example:
1490
1491              > put(key1, {merry, lambs, are, playing}),
1492              X = erase(key1),
1493              {X, erase(key1)}.
1494              {{merry,lambs,are,playing},undefined}
1495
1496       error(Reason) -> no_return()
1497
1498              Types:
1499
1500                 Reason = term()
1501
1502              Stops the execution of the calling process with the reason  Rea‐
1503              son,  where  Reason  is  any  term.  The exit reason is {Reason,
1504              Where}, where Where is a list of  the  functions  most  recently
1505              called (the current function first). As evaluating this function
1506              causes the process to terminate, it has no return  value.  Exam‐
1507              ple:
1508
1509              > catch error(foobar).
1510              {'EXIT',{foobar,[{shell,apply_fun,3,
1511                                      [{file,"shell.erl"},{line,906}]},
1512                               {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,677}]},
1513                               {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,430}]},
1514                               {shell,exprs,7,[{file,"shell.erl"},{line,687}]},
1515                               {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
1516                               {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}}
1517
1518
1519       error(Reason, Args) -> no_return()
1520
1521              Types:
1522
1523                 Reason = term()
1524                 Args = [term()]
1525
1526              Stops  the execution of the calling process with the reason Rea‐
1527              son, where Reason is any  term.  The  exit  reason  is  {Reason,
1528              Where},  where  Where  is  a list of the functions most recently
1529              called (the current function first). Args is expected to be  the
1530              list  of  arguments for the current function; in Beam it is used
1531              to provide the arguments for the current function  in  the  term
1532              Where.  As evaluating this function causes the process to termi‐
1533              nate, it has no return value.
1534
1535       exit(Reason) -> no_return()
1536
1537              Types:
1538
1539                 Reason = term()
1540
1541              Stops the execution of the calling process with exit reason Rea‐
1542              son,  where  Reason  is  any  term.  As evaluating this function
1543              causes the process to terminate, it has no return  value.  Exam‐
1544              ple:
1545
1546              > exit(foobar).
1547              ** exception exit: foobar
1548              > catch exit(foobar).
1549              {'EXIT',foobar}
1550
1551       exit(Pid, Reason) -> true
1552
1553              Types:
1554
1555                 Pid = pid() | port()
1556                 Reason = term()
1557
1558              Sends  an  exit signal with exit reason Reason to the process or
1559              port identified by Pid.
1560
1561              The following behavior applies if Reason  is  any  term,  except
1562              normal or kill:
1563
1564                * If  Pid  is  not  trapping exits, Pid itself exits with exit
1565                  reason Reason.
1566
1567                * If Pid is trapping exits, the  exit  signal  is  transformed
1568                  into  a  message {'EXIT', From, Reason} and delivered to the
1569                  message queue of Pid.
1570
1571                * From is the process identifier of the process that sent  the
1572                  exit signal. See also process_flag/2.
1573
1574              If  Reason is the atom normal, Pid does not exit. If it is trap‐
1575              ping exits, the  exit  signal  is  transformed  into  a  message
1576              {'EXIT', From, normal} and delivered to its message queue.
1577
1578              If  Reason  is  the  atom  kill,  that is, if exit(Pid, kill) is
1579              called, an untrappable exit signal is sent to Pid, which  uncon‐
1580              ditionally exits with exit reason killed.
1581
1582       erlang:external_size(Term) -> integer() >= 0
1583
1584              Types:
1585
1586                 Term = term()
1587
1588              Calculates,  without  doing  the encoding, the maximum byte size
1589              for a term encoded in the Erlang external term format. The  fol‐
1590              lowing condition applies always:
1591
1592              > Size1 = byte_size(term_to_binary(Term)),
1593              > Size2 = erlang:external_size(Term),
1594              > true = Size1 =< Size2.
1595              true
1596
1597              This is equivalent to a call to:
1598
1599              erlang:external_size(Term, [])
1600
1601       erlang:external_size(Term, Options) -> integer() >= 0
1602
1603              Types:
1604
1605                 Term = term()
1606                 Options = [{minor_version, Version :: integer() >= 0}]
1607
1608              Calculates,  without  doing  the encoding, the maximum byte size
1609              for a term encoded in the Erlang external term format. The  fol‐
1610              lowing condition applies always:
1611
1612              > Size1 = byte_size(term_to_binary(Term, Options)),
1613              > Size2 = erlang:external_size(Term, Options),
1614              > true = Size1 =< Size2.
1615              true
1616
1617              Option   {minor_version,   Version}  specifies  how  floats  are
1618              encoded. For a detailed description, see term_to_binary/2.
1619
1620       float(Number) -> float()
1621
1622              Types:
1623
1624                 Number = number()
1625
1626              Returns a float by converting Number to a float, for example:
1627
1628              > float(55).
1629              55.0
1630
1631              Allowed in guard tests.
1632
1633          Note:
1634              If used on the top level in a guard, it tests whether the  argu‐
1635              ment  is  a  floating  point number; for clarity, use is_float/1
1636              instead.
1637
1638              When float/1 is used in  an  expression  in  a  guard,  such  as
1639              'float(A) == 4.0', it converts a number as described earlier.
1640
1641
1642       float_to_binary(Float) -> binary()
1643
1644              Types:
1645
1646                 Float = float()
1647
1648              The same as float_to_binary(Float,[{scientific,20}]).
1649
1650       float_to_binary(Float, Options) -> binary()
1651
1652              Types:
1653
1654                 Float = float()
1655                 Options = [Option]
1656                 Option =
1657                     {decimals, Decimals :: 0..253} |
1658                     {scientific, Decimals :: 0..249} |
1659                     compact
1660
1661              Returns  a  binary  corresponding  to the text representation of
1662              Float using fixed decimal point formatting. Options  behaves  in
1663              the same way as float_to_list/2. Examples:
1664
1665              > float_to_binary(7.12, [{decimals, 4}]).
1666              <<"7.1200">>
1667              > float_to_binary(7.12, [{decimals, 4}, compact]).
1668              <<"7.12">>
1669
1670       float_to_list(Float) -> string()
1671
1672              Types:
1673
1674                 Float = float()
1675
1676              The same as float_to_list(Float,[{scientific,20}]).
1677
1678       float_to_list(Float, Options) -> string()
1679
1680              Types:
1681
1682                 Float = float()
1683                 Options = [Option]
1684                 Option =
1685                     {decimals, Decimals :: 0..253} |
1686                     {scientific, Decimals :: 0..249} |
1687                     compact
1688
1689              Returns  a  string  corresponding  to the text representation of
1690              Float using fixed decimal point formatting.
1691
1692              Available options:
1693
1694                * If option decimals is specified, the returned value contains
1695                  at most Decimals number of digits past the decimal point. If
1696                  the number does not fit in the internal static buffer of 256
1697                  bytes, the function throws badarg.
1698
1699                * If  option  compact  is specified, the trailing zeros at the
1700                  end of the list are truncated. This option is only  meaning‐
1701                  ful together with option decimals.
1702
1703                * If  option  scientific  is specified, the float is formatted
1704                  using scientific notation with Decimals digits of precision.
1705
1706                * If Options is [], the function behaves as float_to_list/1.
1707
1708              Examples:
1709
1710              > float_to_list(7.12, [{decimals, 4}]).
1711              "7.1200"
1712              > float_to_list(7.12, [{decimals, 4}, compact]).
1713              "7.12"
1714
1715       floor(Number) -> integer()
1716
1717              Types:
1718
1719                 Number = number()
1720
1721              Returns the largest integer not greater than Number.  For  exam‐
1722              ple:
1723
1724              > floor(-10.5).
1725              -11
1726
1727              Allowed in guard tests.
1728
1729       erlang:fun_info(Fun) -> [{Item, Info}]
1730
1731              Types:
1732
1733                 Fun = function()
1734                 Item =
1735                     arity  |  env  |  index  |  name  |  module | new_index |
1736                 new_uniq |
1737                     pid | type | uniq
1738                 Info = term()
1739
1740              Returns a list with information about the  fun  Fun.  Each  list
1741              element  is  a  tuple. The order of the tuples is undefined, and
1742              more tuples can be added in a future release.
1743
1744          Warning:
1745              This BIF is mainly intended for debugging, but it can  sometimes
1746              be useful in library functions that need to verify, for example,
1747              the arity of a fun.
1748
1749
1750              Two types of funs have slightly different semantics:
1751
1752                * A fun created by fun M:F/A is called an external fun.  Call‐
1753                  ing  it  will always call the function F with arity A in the
1754                  latest code for module M. Notice that module M does not even
1755                  need to be loaded when the fun fun M:F/A is created.
1756
1757                * All other funs are called local. When a local fun is called,
1758                  the same version of the code that created the fun is  called
1759                  (even if a newer version of the module has been loaded).
1760
1761              The  following  elements are always present in the list for both
1762              local and external funs:
1763
1764                {type, Type}:
1765                  Type is local or external.
1766
1767                {module, Module}:
1768                  Module (an atom) is the module name.
1769
1770                  If Fun is a local fun, Module is the module in which the fun
1771                  is defined.
1772
1773                  If Fun is an external fun, Module is the module that the fun
1774                  refers to.
1775
1776                {name, Name}:
1777                  Name (an atom) is a function name.
1778
1779                  If Fun is a local fun, Name is the name of the  local  func‐
1780                  tion  that  implements  the fun. (This name was generated by
1781                  the compiler, and is only of informational use. As it  is  a
1782                  local function, it cannot be called directly.) If no code is
1783                  currently loaded for the fun, [] is returned instead  of  an
1784                  atom.
1785
1786                  If  Fun is an external fun, Name is the name of the exported
1787                  function that the fun refers to.
1788
1789                {arity, Arity}:
1790                  Arity is the number of arguments  that  the  fun  is  to  be
1791                  called with.
1792
1793                {env, Env}:
1794                  Env  (a  list)  is the environment or free variables for the
1795                  fun. For external funs, the returned list is always empty.
1796
1797              The following elements are only present in the list  if  Fun  is
1798              local:
1799
1800                {pid, Pid}:
1801                  Pid is the process identifier of the process that originally
1802                  created the fun.
1803
1804                  It might point to the init process if the Fun was statically
1805                  allocated  when module was loaded (this optimisation is per‐
1806                  formed for local functions that do not capture the  environ‐
1807                  ment).
1808
1809                {index, Index}:
1810                  Index (an integer) is an index into the module fun table.
1811
1812                {new_index, Index}:
1813                  Index (an integer) is an index into the module fun table.
1814
1815                {new_uniq, Uniq}:
1816                  Uniq (a binary) is a unique value for this fun. It is calcu‐
1817                  lated from the compiled code for the entire module.
1818
1819                {uniq, Uniq}:
1820                  Uniq (an integer) is a unique value for this  fun.  As  from
1821                  Erlang/OTP R15, this integer is calculated from the compiled
1822                  code for the entire  module.  Before  Erlang/OTP  R15,  this
1823                  integer was based on only the body of the fun.
1824
1825       erlang:fun_info(Fun, Item) -> {Item, Info}
1826
1827              Types:
1828
1829                 Fun = function()
1830                 Item = fun_info_item()
1831                 Info = term()
1832                 fun_info_item() =
1833                     arity | env | index | name | module | new_index | new_uniq |
1834                     pid | type | uniq
1835
1836              Returns  information about Fun as specified by Item, in the form
1837              {Item,Info}.
1838
1839              For any fun, Item can be any of the atoms module,  name,  arity,
1840              env, or type.
1841
1842              For  a  local  fun,  Item  can  also  be any of the atoms index,
1843              new_index, new_uniq, uniq, and pid. For  an  external  fun,  the
1844              value of any of these items is always the atom undefined.
1845
1846              See erlang:fun_info/1.
1847
1848       erlang:fun_to_list(Fun) -> string()
1849
1850              Types:
1851
1852                 Fun = function()
1853
1854              Returns  a  string  corresponding  to the text representation of
1855              Fun.
1856
1857       erlang:function_exported(Module, Function, Arity) -> boolean()
1858
1859              Types:
1860
1861                 Module = module()
1862                 Function = atom()
1863                 Arity = arity()
1864
1865              Returns true if the module Module  is  loaded  and  contains  an
1866              exported function Function/Arity, or if there is a BIF (a built-
1867              in function implemented in C) with the specified name, otherwise
1868              returns false.
1869
1870          Note:
1871              This  function  used  to return false for BIFs before Erlang/OTP
1872              18.0.
1873
1874
1875       garbage_collect() -> true
1876
1877              Forces an immediate garbage collection of the executing process.
1878              The  function  is  not to be used unless it has been noticed (or
1879              there are good reasons to suspect) that the spontaneous  garbage
1880              collection will occur too late or not at all.
1881
1882          Warning:
1883              Improper use can seriously degrade system performance.
1884
1885
1886       garbage_collect(Pid) -> GCResult
1887
1888              Types:
1889
1890                 Pid = pid()
1891                 GCResult = boolean()
1892
1893              The same as garbage_collect(Pid, []).
1894
1895       garbage_collect(Pid, OptionList) -> GCResult | async
1896
1897              Types:
1898
1899                 Pid = pid()
1900                 RequestId = term()
1901                 Option = {async, RequestId} | {type, major | minor}
1902                 OptionList = [Option]
1903                 GCResult = boolean()
1904
1905              Garbage collects the node local process identified by Pid.
1906
1907              Option:
1908
1909                {async, RequestId}:
1910                  The function garbage_collect/2 returns the value async imme‐
1911                  diately after the request has been sent.  When  the  request
1912                  has been processed, the process that called this function is
1913                  passed a message on the  form  {garbage_collect,  RequestId,
1914                  GCResult}.
1915
1916                {type, 'major' | 'minor'}:
1917                  Triggers garbage collection of requested type. Default value
1918                  is 'major', which would trigger a fullsweep GC.  The  option
1919                  'minor' is considered a hint and may lead to either minor or
1920                  major GC run.
1921
1922              If Pid equals self(), and no async option has been  passed,  the
1923              garbage  collection  is  performed at once, that is, the same as
1924              calling garbage_collect/0. Otherwise a request for garbage  col‐
1925              lection  is  sent  to the process identified by Pid, and will be
1926              handled when appropriate. If no async option  has  been  passed,
1927              the  caller  blocks  until  GCResult  is  available  and  can be
1928              returned.
1929
1930              GCResult informs about the  result  of  the  garbage  collection
1931              request as follows:
1932
1933                true:
1934                   The process identified by Pid has been garbage collected.
1935
1936                false:
1937                   No garbage collection was performed, as the process identi‐
1938                  fied by Pid terminated before the request  could  be  satis‐
1939                  fied.
1940
1941              Notice that the same caveats apply as for garbage_collect/0.
1942
1943              Failures:
1944
1945                badarg:
1946                   If Pid is not a node local process identifier.
1947
1948                badarg:
1949                   If OptionList is an invalid list of options.
1950
1951       get() -> [{Key, Val}]
1952
1953              Types:
1954
1955                 Key = Val = term()
1956
1957              Returns  the  process dictionary as a list of {Key, Val} tuples,
1958              for example:
1959
1960              > put(key1, merry),
1961              put(key2, lambs),
1962              put(key3, {are, playing}),
1963              get().
1964              [{key1,merry},{key2,lambs},{key3,{are,playing}}]
1965
1966       get(Key) -> Val | undefined
1967
1968              Types:
1969
1970                 Key = Val = term()
1971
1972              Returns the value Val associated with Key in the process dictio‐
1973              nary, or undefined if Key does not exist. Example:
1974
1975              > put(key1, merry),
1976              put(key2, lambs),
1977              put({any, [valid, term]}, {are, playing}),
1978              get({any, [valid, term]}).
1979              {are,playing}
1980
1981       erlang:get_cookie() -> Cookie | nocookie
1982
1983              Types:
1984
1985                 Cookie = atom()
1986
1987              Returns the magic cookie of the local node if the node is alive,
1988              otherwise the atom nocookie.
1989
1990       get_keys() -> [Key]
1991
1992              Types:
1993
1994                 Key = term()
1995
1996              Returns a list of all keys present in  the  process  dictionary,
1997              for example:
1998
1999              > put(dog, {animal,1}),
2000              put(cow, {animal,2}),
2001              put(lamb, {animal,3}),
2002              get_keys().
2003              [dog,cow,lamb]
2004
2005       get_keys(Val) -> [Key]
2006
2007              Types:
2008
2009                 Val = Key = term()
2010
2011              Returns a list of keys that are associated with the value Val in
2012              the process dictionary, for example:
2013
2014              > put(mary, {1, 2}),
2015              put(had, {1, 2}),
2016              put(a, {1, 2}),
2017              put(little, {1, 2}),
2018              put(dog, {1, 3}),
2019              put(lamb, {1, 2}),
2020              get_keys({1, 2}).
2021              [mary,had,a,little,lamb]
2022
2023       erlang:get_stacktrace() -> [stack_item()]
2024
2025              Types:
2026
2027                 stack_item() =
2028                     {Module :: module(),
2029                      Function :: atom(),
2030                      Arity :: arity() | (Args :: [term()]),
2031                      Location ::
2032                          [{file, Filename :: string()} |
2033                           {line, Line :: integer() >= 1}]}
2034
2035          Warning:
2036              erlang:get_stacktrace/0 is deprecated and will be removed in OTP
2037              24. Starting from OTP 23, erlang:get_stacktrace/0 returns [].
2038
2039
2040              Instead  of  using  erlang:get_stacktrace/0 to retrieve the call
2041              stack back-trace, use the following syntax:
2042
2043              try Expr
2044              catch
2045                Class:Reason:Stacktrace ->
2046                 {Class,Reason,Stacktrace}
2047              end
2048
2049       group_leader() -> pid()
2050
2051              Returns the process identifier  of  the  group  leader  for  the
2052              process evaluating the function.
2053
2054              Every  process  is a member of some process group and all groups
2055              have a group leader. All I/O from the group is channeled to  the
2056              group  leader.  When  a new process is spawned, it gets the same
2057              group leader as  the  spawning  process.  Initially,  at  system
2058              startup,  init is both its own group leader and the group leader
2059              of all processes.
2060
2061       group_leader(GroupLeader, Pid) -> true
2062
2063              Types:
2064
2065                 GroupLeader = Pid = pid()
2066
2067              Sets the group leader of Pid to GroupLeader. Typically, this  is
2068              used  when  a  process  started  from a certain shell is to have
2069              another group leader than init.
2070
2071              The group leader should be rarely changed in applications with a
2072              supervision  tree, because OTP assumes the group leader of their
2073              processes is their application master.
2074
2075              See also group_leader/0 and OTP  design  principles  related  to
2076              starting and stopping applications.
2077
2078       halt() -> no_return()
2079
2080              The same as halt(0, []). Example:
2081
2082              > halt().
2083              os_prompt%
2084
2085       halt(Status) -> no_return()
2086
2087              Types:
2088
2089                 Status = integer() >= 0 | abort | string()
2090
2091              The same as halt(Status, []). Example:
2092
2093              > halt(17).
2094              os_prompt% echo $?
2095              17
2096              os_prompt%
2097
2098       halt(Status, Options) -> no_return()
2099
2100              Types:
2101
2102                 Status = integer() >= 0 | abort | string()
2103                 Options = [Option]
2104                 Option = {flush, boolean()}
2105
2106              Status  must  be  a  non-negative integer, a string, or the atom
2107              abort. Halts the Erlang runtime system.  Has  no  return  value.
2108              Depending on Status, the following occurs:
2109
2110                integer():
2111                  The runtime system exits with integer value Status as status
2112                  code to the calling environment (OS).
2113
2114            Note:
2115                On many platforms, the OS supports only status codes 0-255.  A
2116                too large status code is truncated by clearing the high bits.
2117
2118
2119                string():
2120                  An Erlang crash dump is produced with Status as slogan. Then
2121                  the runtime system exits with status code 1. The string will
2122                  be truncated if longer than 200 characters.
2123
2124            Note:
2125                Before ERTS 9.1 (OTP-20.1) only code points in the range 0-255
2126                was accepted in the string. Now any unicode string is valid.
2127
2128
2129                abort:
2130                  The runtime system aborts producing a core dump, if that  is
2131                  enabled in the OS.
2132
2133              For  integer  Status, the Erlang runtime system closes all ports
2134              and allows async threads to finish their operations before exit‐
2135              ing. To exit without such flushing, use Option as {flush,false}.
2136
2137              For  statuses  string()  and  abort, option flush is ignored and
2138              flushing is not done.
2139
2140       hd(List) -> term()
2141
2142              Types:
2143
2144                 List = [term(), ...]
2145
2146              Returns the head of List, that is, the first element, for  exam‐
2147              ple:
2148
2149              > hd([1,2,3,4,5]).
2150              1
2151
2152              Allowed in guard tests.
2153
2154              Failure: badarg if List is the empty list [].
2155
2156       erlang:hibernate(Module, Function, Args) -> no_return()
2157
2158              Types:
2159
2160                 Module = module()
2161                 Function = atom()
2162                 Args = [term()]
2163
2164              Puts  the  calling  process  into  a wait state where its memory
2165              allocation has been reduced as much as possible. This is  useful
2166              if the process does not expect to receive any messages soon.
2167
2168              The  process is awaken when a message is sent to it, and control
2169              resumes in Module:Function with the arguments specified by  Args
2170              with the call stack emptied, meaning that the process terminates
2171              when  that  function  returns.  Thus  erlang:hibernate/3   never
2172              returns to its caller.
2173
2174              If the process has any message in its message queue, the process
2175              is awakened immediately in the same way as described earlier.
2176
2177              In more technical terms, erlang:hibernate/3  discards  the  call
2178              stack  for  the  process, and then garbage collects the process.
2179              After this, all live data is in one continuous heap. The heap is
2180              then  shrunken  to  the exact same size as the live data that it
2181              holds (even if that size is less than the minimum heap size  for
2182              the process).
2183
2184              If  the  size  of  the live data in the process is less than the
2185              minimum heap size, the first garbage collection occurring  after
2186              the process is awakened ensures that the heap size is changed to
2187              a size not smaller than the minimum heap size.
2188
2189              Notice that emptying the call stack means that  any  surrounding
2190              catch  is removed and must be re-inserted after hibernation. One
2191              effect of this is that processes started  using  proc_lib  (also
2192              indirectly,   such   as   gen_server   processes),  are  to  use
2193              proc_lib:hibernate/3 instead, to ensure that the exception  han‐
2194              dler continues to work when the process wakes up.
2195
2196       erlang:insert_element(Index, Tuple1, Term) -> Tuple2
2197
2198              Types:
2199
2200                 Index = integer() >= 1
2201                   1..tuple_size(Tuple1) + 1
2202                 Tuple1 = Tuple2 = tuple()
2203                 Term = term()
2204
2205              Returns a new tuple with element Term inserted at position Index
2206              in tuple Tuple1. All elements from position  Index  and  upwards
2207              are pushed one step higher in the new tuple Tuple2. Example:
2208
2209              > erlang:insert_element(2, {one, two, three}, new).
2210              {one,new,two,three}
2211
2212       integer_to_binary(Integer) -> binary()
2213
2214              Types:
2215
2216                 Integer = integer()
2217
2218              Returns  a  binary  corresponding  to the text representation of
2219              Integer, for example:
2220
2221              > integer_to_binary(77).
2222              <<"77">>
2223
2224       integer_to_binary(Integer, Base) -> binary()
2225
2226              Types:
2227
2228                 Integer = integer()
2229                 Base = 2..36
2230
2231              Returns a binary corresponding to  the  text  representation  of
2232              Integer in base Base, for example:
2233
2234              > integer_to_binary(1023, 16).
2235              <<"3FF">>
2236
2237       integer_to_list(Integer) -> string()
2238
2239              Types:
2240
2241                 Integer = integer()
2242
2243              Returns  a  string  corresponding  to the text representation of
2244              Integer, for example:
2245
2246              > integer_to_list(77).
2247              "77"
2248
2249       integer_to_list(Integer, Base) -> string()
2250
2251              Types:
2252
2253                 Integer = integer()
2254                 Base = 2..36
2255
2256              Returns a string corresponding to  the  text  representation  of
2257              Integer in base Base, for example:
2258
2259              > integer_to_list(1023, 16).
2260              "3FF"
2261
2262       iolist_size(Item) -> integer() >= 0
2263
2264              Types:
2265
2266                 Item = iolist() | binary()
2267
2268              Returns  an  integer,  that  is the size in bytes, of the binary
2269              that would be the result of iolist_to_binary(Item), for example:
2270
2271              > iolist_size([1,2|<<3,4>>]).
2272              4
2273
2274       iolist_to_binary(IoListOrBinary) -> binary()
2275
2276              Types:
2277
2278                 IoListOrBinary = iolist() | binary()
2279
2280              Returns a binary that is made from the integers and binaries  in
2281              IoListOrBinary, for example:
2282
2283              > Bin1 = <<1,2,3>>.
2284              <<1,2,3>>
2285              > Bin2 = <<4,5>>.
2286              <<4,5>>
2287              > Bin3 = <<6>>.
2288              <<6>>
2289              > iolist_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).
2290              <<1,2,3,1,2,3,4,5,4,6>>
2291
2292       erlang:iolist_to_iovec(IoListOrBinary) -> iovec()
2293
2294              Types:
2295
2296                 IoListOrBinary = iolist() | binary()
2297
2298              Returns  an iovec that is made from the integers and binaries in
2299              IoListOrBinary.
2300
2301       is_alive() -> boolean()
2302
2303              Returns true if the local node is alive (that is,  if  the  node
2304              can be part of a distributed system), otherwise false.
2305
2306       is_atom(Term) -> boolean()
2307
2308              Types:
2309
2310                 Term = term()
2311
2312              Returns true if Term is an atom, otherwise false.
2313
2314              Allowed in guard tests.
2315
2316       is_binary(Term) -> boolean()
2317
2318              Types:
2319
2320                 Term = term()
2321
2322              Returns true if Term is a binary, otherwise false.
2323
2324              A binary always contains a complete number of bytes.
2325
2326              Allowed in guard tests.
2327
2328       is_bitstring(Term) -> boolean()
2329
2330              Types:
2331
2332                 Term = term()
2333
2334              Returns true if Term is a bitstring (including a binary), other‐
2335              wise false.
2336
2337              Allowed in guard tests.
2338
2339       is_boolean(Term) -> boolean()
2340
2341              Types:
2342
2343                 Term = term()
2344
2345              Returns true if Term is the atom true or the  atom  false  (that
2346              is, a boolean). Otherwise returns false.
2347
2348              Allowed in guard tests.
2349
2350       erlang:is_builtin(Module, Function, Arity) -> boolean()
2351
2352              Types:
2353
2354                 Module = module()
2355                 Function = atom()
2356                 Arity = arity()
2357
2358              This BIF is useful for builders of cross-reference tools.
2359
2360              Returns true if Module:Function/Arity is a BIF implemented in C,
2361              otherwise false.
2362
2363       is_float(Term) -> boolean()
2364
2365              Types:
2366
2367                 Term = term()
2368
2369              Returns true if Term  is  a  floating  point  number,  otherwise
2370              false.
2371
2372              Allowed in guard tests.
2373
2374       is_function(Term) -> boolean()
2375
2376              Types:
2377
2378                 Term = term()
2379
2380              Returns true if Term is a fun, otherwise false.
2381
2382              Allowed in guard tests.
2383
2384       is_function(Term, Arity) -> boolean()
2385
2386              Types:
2387
2388                 Term = term()
2389                 Arity = arity()
2390
2391              Returns  true  if  Term  is a fun that can be applied with Arity
2392              number of arguments, otherwise false.
2393
2394              Allowed in guard tests.
2395
2396       is_integer(Term) -> boolean()
2397
2398              Types:
2399
2400                 Term = term()
2401
2402              Returns true if Term is an integer, otherwise false.
2403
2404              Allowed in guard tests.
2405
2406       is_list(Term) -> boolean()
2407
2408              Types:
2409
2410                 Term = term()
2411
2412              Returns true if Term is a list with zero or more elements,  oth‐
2413              erwise false.
2414
2415              Allowed in guard tests.
2416
2417       is_map(Term) -> boolean()
2418
2419              Types:
2420
2421                 Term = term()
2422
2423              Returns true if Term is a map, otherwise false.
2424
2425              Allowed in guard tests.
2426
2427       is_map_key(Key, Map) -> boolean()
2428
2429              Types:
2430
2431                 Key = term()
2432                 Map = map()
2433
2434              Returns  true  if  map  Map contains Key and returns false if it
2435              does not contain the Key.
2436
2437              The call fails with a {badmap,Map} exception if  Map  is  not  a
2438              map.
2439
2440              Example:
2441
2442              > Map = #{"42" => value}.
2443              #{"42" => value}
2444              > is_map_key("42",Map).
2445              true
2446              > is_map_key(value,Map).
2447              false
2448
2449              Allowed in guard tests.
2450
2451       is_number(Term) -> boolean()
2452
2453              Types:
2454
2455                 Term = term()
2456
2457              Returns  true  if Term is an integer or a floating point number.
2458              Otherwise returns false.
2459
2460              Allowed in guard tests.
2461
2462       is_pid(Term) -> boolean()
2463
2464              Types:
2465
2466                 Term = term()
2467
2468              Returns true if Term is a process identifier, otherwise false.
2469
2470              Allowed in guard tests.
2471
2472       is_port(Term) -> boolean()
2473
2474              Types:
2475
2476                 Term = term()
2477
2478              Returns true if Term is a port identifier, otherwise false.
2479
2480              Allowed in guard tests.
2481
2482       is_process_alive(Pid) -> boolean()
2483
2484              Types:
2485
2486                 Pid = pid()
2487
2488              Pid must refer to a process at the local node.
2489
2490              Returns true if the process exists and is alive, that is, is not
2491              exiting and has not exited. Otherwise returns false.
2492
2493       is_record(Term, RecordTag) -> boolean()
2494
2495              Types:
2496
2497                 Term = term()
2498                 RecordTag = atom()
2499
2500              Returns true if Term is a tuple and its first element is Record‐
2501              Tag. Otherwise returns false.
2502
2503          Note:
2504              Normally the compiler treats calls to is_record/2 especially. It
2505              emits  code  to verify that Term is a tuple, that its first ele‐
2506              ment is RecordTag, and that the size  is  correct.  However,  if
2507              RecordTag  is  not a literal atom, the BIF is_record/2 is called
2508              instead and the size of the tuple is not verified.
2509
2510
2511              Allowed in guard tests, if RecordTag is a literal atom.
2512
2513       is_record(Term, RecordTag, Size) -> boolean()
2514
2515              Types:
2516
2517                 Term = term()
2518                 RecordTag = atom()
2519                 Size = integer() >= 0
2520
2521              RecordTag must be an atom.
2522
2523              Returns true if Term is a tuple, its first element is RecordTag,
2524              and its size is Size. Otherwise returns false.
2525
2526              Allowed  in  guard tests if RecordTag is a literal atom and Size
2527              is a literal integer.
2528
2529          Note:
2530              This BIF is documented for completeness. Usually is_record/2  is
2531              to be used.
2532
2533
2534       is_reference(Term) -> boolean()
2535
2536              Types:
2537
2538                 Term = term()
2539
2540              Returns true if Term is a reference, otherwise false.
2541
2542              Allowed in guard tests.
2543
2544       is_tuple(Term) -> boolean()
2545
2546              Types:
2547
2548                 Term = term()
2549
2550              Returns true if Term is a tuple, otherwise false.
2551
2552              Allowed in guard tests.
2553
2554       length(List) -> integer() >= 0
2555
2556              Types:
2557
2558                 List = [term()]
2559
2560              Returns the length of List, for example:
2561
2562              > length([1,2,3,4,5,6,7,8,9]).
2563              9
2564
2565              Allowed in guard tests.
2566
2567       link(PidOrPort) -> true
2568
2569              Types:
2570
2571                 PidOrPort = pid() | port()
2572
2573              Sets  up  and  activates  a link between the calling process and
2574              another process or a port identified by PidOrPort. We will  from
2575              here  on call the identified process or port linkee. If the lin‐
2576              kee is a port, it must reside on the same node as the caller.
2577
2578              If one of the participants of a link terminates, it will send an
2579              exit  signal to the other participant. The exit signal will con‐
2580              tain the exit reason of the terminated participant. Other  cases
2581              when exit signals are triggered due to a link are when no linkee
2582              exist (noproc exit  reason)  and  when  the  connection  between
2583              linked  processes on different nodes is lost or cannot be estab‐
2584              lished (noconnection exit reason).
2585
2586              An existing link can be removed by calling  unlink/1.  For  more
2587              information on links and exit signals due to links, see the Pro‐
2588              cesses  chapter in the Erlang Reference Manual :
2589
2590                * Links
2591
2592                * Sending Exit Signals
2593
2594                * Receiving Exit Signals
2595
2596              For historical reasons, link/1 has  a  strange  semi-synchronous
2597              behavior  when  it  is  "cheap" to check if the linkee exists or
2598              not, and the caller does not trap exits. If the  above  is  true
2599              and  the linkee does not exist, link/1 will raise a noproc error
2600              exception. The expected behavior would instead  have  been  that
2601              link/1 returned true, and the caller later was sent an exit sig‐
2602              nal with noproc exit reason, but this is unfortunately  not  the
2603              case.  The  noproc  exception is not to be confused with an exit
2604              signal with exit reason noproc. Currently it is "cheap" to check
2605              if  the  linkee exists when it is supposed to reside on the same
2606              node as the calling process.
2607
2608              The link setup and activation is  performed  asynchronously.  If
2609              the  link  already exists, or if the caller attempts to create a
2610              link to itself, nothing is done. A detailed description  of  the
2611              link protocol can be found in the Distribution Protocol  chapter
2612              of the ERTS User's Guide .
2613
2614              Failure:
2615
2616                * badarg if PidOrPort does not identify a process  or  a  node
2617                  local port.
2618
2619                * noproc  linkee  does not exist and it is "cheap" to check if
2620                  it exists as described above.
2621
2622       list_to_atom(String) -> atom()
2623
2624              Types:
2625
2626                 String = string()
2627
2628              Returns the atom whose text representation is String.
2629
2630              As from Erlang/OTP 20, String may contain any Unicode character.
2631              Earlier  versions  allowed  only  ISO-latin-1  characters as the
2632              implementation did not allow Unicode characters above  255.  For
2633              more  information on Unicode support in atoms, see note on UTF-8
2634              encoded atoms in section "External Term Format"  in  the  User's
2635              Guide.
2636
2637              Example:
2638
2639              > list_to_atom("Erlang").
2640
2641       list_to_binary(IoList) -> binary()
2642
2643              Types:
2644
2645                 IoList = iolist()
2646
2647              Returns  a binary that is made from the integers and binaries in
2648              IoList, for example:
2649
2650              > Bin1 = <<1,2,3>>.
2651              <<1,2,3>>
2652              > Bin2 = <<4,5>>.
2653              <<4,5>>
2654              > Bin3 = <<6>>.
2655              <<6>>
2656              > list_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]).
2657              <<1,2,3,1,2,3,4,5,4,6>>
2658
2659       list_to_bitstring(BitstringList) -> bitstring()
2660
2661              Types:
2662
2663                 BitstringList = bitstring_list()
2664                 bitstring_list() =
2665                     maybe_improper_list(byte() | bitstring() | bitstring_list(),
2666                                         bitstring() | [])
2667
2668              Returns a bitstring that is made  from  the  integers  and  bit‐
2669              strings  in  BitstringList.  (The  last tail in BitstringList is
2670              allowed to be a bitstring.) Example:
2671
2672              > Bin1 = <<1,2,3>>.
2673              <<1,2,3>>
2674              > Bin2 = <<4,5>>.
2675              <<4,5>>
2676              > Bin3 = <<6,7:4>>.
2677              <<6,7:4>>
2678              > list_to_bitstring([Bin1,1,[2,3,Bin2],4|Bin3]).
2679              <<1,2,3,1,2,3,4,5,4,6,7:4>>
2680
2681       list_to_existing_atom(String) -> atom()
2682
2683              Types:
2684
2685                 String = string()
2686
2687              Returns the atom whose text representation is String,  but  only
2688              if there already exists such atom.
2689
2690              Failure:  badarg  if  there does not already exist an atom whose
2691              text representation is String.
2692
2693          Note:
2694              Note that the compiler may optimize away atoms. For example, the
2695              compiler will rewrite atom_to_list(some_atom) to "some_atom". If
2696              that expression is the only mention of the atom some_atom in the
2697              containing  module, the atom will not be created when the module
2698              is   loaded,   and   a   subsequent   call   to   list_to_exist‐
2699              ing_atom("some_atom") will fail.
2700
2701
2702       list_to_float(String) -> float()
2703
2704              Types:
2705
2706                 String = string()
2707
2708              Returns the float whose text representation is String, for exam‐
2709              ple:
2710
2711              > list_to_float("2.2017764e+0").
2712              2.2017764
2713
2714              Failure: badarg if String contains a  bad  representation  of  a
2715              float.
2716
2717       list_to_integer(String) -> integer()
2718
2719              Types:
2720
2721                 String = string()
2722
2723              Returns  an  integer  whose  text  representation is String, for
2724              example:
2725
2726              > list_to_integer("123").
2727              123
2728
2729              Failure: badarg if String contains a bad  representation  of  an
2730              integer.
2731
2732       list_to_integer(String, Base) -> integer()
2733
2734              Types:
2735
2736                 String = string()
2737                 Base = 2..36
2738
2739              Returns  an  integer  whose  text representation in base Base is
2740              String, for example:
2741
2742              > list_to_integer("3FF", 16).
2743              1023
2744
2745              Failure: badarg if String contains a bad  representation  of  an
2746              integer.
2747
2748       list_to_pid(String) -> pid()
2749
2750              Types:
2751
2752                 String = string()
2753
2754              Returns  a  process  identifier  whose  text representation is a
2755              String, for example:
2756
2757              > list_to_pid("<0.4.1>").
2758              <0.4.1>
2759
2760              Failure: badarg if String contains a  bad  representation  of  a
2761              process identifier.
2762
2763          Warning:
2764              This  BIF  is  intended  for  debugging and is not to be used in
2765              application programs.
2766
2767
2768       list_to_port(String) -> port()
2769
2770              Types:
2771
2772                 String = string()
2773
2774              Returns a port identifier whose text representation is a String,
2775              for example:
2776
2777              > list_to_port("#Port<0.4>").
2778              #Port<0.4>
2779
2780              Failure:  badarg  if  String  contains a bad representation of a
2781              port identifier.
2782
2783          Warning:
2784              This BIF is intended for debugging and is  not  to  be  used  in
2785              application programs.
2786
2787
2788       list_to_ref(String) -> reference()
2789
2790              Types:
2791
2792                 String = string()
2793
2794              Returns  a  reference whose text representation is a String, for
2795              example:
2796
2797              > list_to_ref("#Ref<0.4192537678.4073193475.71181>").
2798              #Ref<0.4192537678.4073193475.71181>
2799
2800              Failure: badarg if String contains a  bad  representation  of  a
2801              reference.
2802
2803          Warning:
2804              This  BIF  is  intended  for  debugging and is not to be used in
2805              application programs.
2806
2807
2808       list_to_tuple(List) -> tuple()
2809
2810              Types:
2811
2812                 List = [term()]
2813
2814              Returns a tuple corresponding to List, for example
2815
2816              > list_to_tuple([share, ['Ericsson_B', 163]]).
2817              {share, ['Ericsson_B', 163]}
2818
2819              List can contain any Erlang terms.
2820
2821       load_module(Module, Binary) -> {module, Module} | {error, Reason}
2822
2823              Types:
2824
2825                 Module = module()
2826                 Binary = binary()
2827                 Reason = badfile | not_purged | on_load
2828
2829              If Binary contains the object code for module Module,  this  BIF
2830              loads  that  object  code. If the code for module Module already
2831              exists, all export references are replaced so they point to  the
2832              newly  loaded  code.  The  previously loaded code is kept in the
2833              system as old code, as there can still  be  processes  executing
2834              that code.
2835
2836              Returns  either  {module, Module}, or {error, Reason} if loading
2837              fails. Reason is one of the following:
2838
2839                badfile:
2840                  The object code in Binary has an  incorrect  format  or  the
2841                  object code contains code for another module than Module.
2842
2843                not_purged:
2844                  Binary  contains  a module that cannot be loaded because old
2845                  code for this module already exists.
2846
2847          Warning:
2848              This BIF is intended for the code server (see  code(3))  and  is
2849              not to be used elsewhere.
2850
2851
2852       erlang:load_nif(Path, LoadInfo) -> ok | Error
2853
2854              Types:
2855
2856                 Path = string()
2857                 LoadInfo = term()
2858                 Error = {error, {Reason, Text :: string()}}
2859                 Reason =
2860                     load_failed  |  bad_lib  |  load  |  reload  |  upgrade |
2861                 old_code
2862
2863              Loads and links a dynamic library containing native  implemented
2864              functions (NIFs) for a module. Path is a file path to the share‐
2865              able object/dynamic library file  minus  the  OS-dependent  file
2866              extension  (.so  for  Unix and .dll for Windows). Notice that on
2867              most OSs the library has to have a different name on  disc  when
2868              an  upgrade of the nif is done. If the name is the same, but the
2869              contents differ, the old library  may  be  loaded  instead.  For
2870              information on how to implement a NIF library, see erl_nif(3).
2871
2872              LoadInfo can be any term. It is passed on to the library as part
2873              of the initialization. A good practice is to  include  a  module
2874              version number to support future code upgrade scenarios.
2875
2876              The  call  to  load_nif/2  must be made directly from the Erlang
2877              code of the module that the NIF library belongs to.  It  returns
2878              either  ok, or {error,{Reason,Text}} if loading fails. Reason is
2879              one of the following atoms while Text is a human readable string
2880              that can give more information about the failure:
2881
2882                load_failed:
2883                  The OS failed to load the NIF library.
2884
2885                bad_lib:
2886                  The  library  did  not  fulfill  the  requirements  as a NIF
2887                  library of the calling module.
2888
2889                load | upgrade:
2890                  The corresponding library callback was unsuccessful.
2891
2892                reload:
2893                  A NIF library is already loaded for  this  module  instance.
2894                  The  previously deprecated reload feature was removed in OTP
2895                  20.
2896
2897                old_code:
2898                  The call to load_nif/2 was made from the old code of a  mod‐
2899                  ule that has been upgraded; this is not allowed.
2900
2901                notsup:
2902                  Lack of support. Such as loading NIF library for a HiPE com‐
2903                  piled module.
2904
2905       erlang:loaded() -> [Module]
2906
2907              Types:
2908
2909                 Module = module()
2910
2911              Returns a list of all loaded Erlang  modules  (current  and  old
2912              code), including preloaded modules.
2913
2914              See also code(3).
2915
2916       erlang:localtime() -> DateTime
2917
2918              Types:
2919
2920                 DateTime = calendar:datetime()
2921
2922              Returns  the  current  local date and time, {{Year, Month, Day},
2923              {Hour, Minute, Second}}, for example:
2924
2925              > erlang:localtime().
2926              {{1996,11,6},{14,45,17}}
2927
2928              The time zone and Daylight Saving Time correction depend on  the
2929              underlying OS.
2930
2931       erlang:localtime_to_universaltime(Localtime) -> Universaltime
2932
2933              Types:
2934
2935                 Localtime = Universaltime = calendar:datetime()
2936
2937              Converts  local  date  and  time  to  Universal Time Coordinated
2938              (UTC), if supported by the underlying OS. Otherwise  no  conver‐
2939              sion is done and Localtime is returned. Example:
2940
2941              > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}).
2942              {{1996,11,6},{13,45,17}}
2943
2944              Failure: badarg if Localtime denotes an invalid date and time.
2945
2946       erlang:localtime_to_universaltime(Localtime, IsDst) ->
2947                                            Universaltime
2948
2949              Types:
2950
2951                 Localtime = Universaltime = calendar:datetime()
2952                 IsDst = true | false | undefined
2953
2954              Converts local date and time to Universal Time Coordinated (UTC)
2955              as erlang:localtime_to_universaltime/1, but the  caller  decides
2956              if Daylight Saving Time is active.
2957
2958              If  IsDst  == true, Localtime is during Daylight Saving Time, if
2959              IsDst == false it is not. If IsDst == undefined, the  underlying
2960              OS  can  guess,  which  is  the  same  as  calling erlang:local‐
2961              time_to_universaltime(Localtime).
2962
2963              Examples:
2964
2965              > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, true).
2966              {{1996,11,6},{12,45,17}}
2967              > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, false).
2968              {{1996,11,6},{13,45,17}}
2969              > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, undefined).
2970              {{1996,11,6},{13,45,17}}
2971
2972              Failure: badarg if Localtime denotes an invalid date and time.
2973
2974       make_ref() -> reference()
2975
2976              Returns a  unique reference. The reference is unique among  con‐
2977              nected nodes.
2978
2979          Warning:
2980              Known  issue:  When  a node is restarted multiple times with the
2981              same node name, references created on a newer node can  be  mis‐
2982              taken  for  a  reference  created on an older node with the same
2983              node name.
2984
2985
2986       erlang:make_tuple(Arity, InitialValue) -> tuple()
2987
2988              Types:
2989
2990                 Arity = arity()
2991                 InitialValue = term()
2992
2993              Creates a new tuple of the specified Arity, where  all  elements
2994              are InitialValue, for example:
2995
2996              > erlang:make_tuple(4, []).
2997              {[],[],[],[]}
2998
2999       erlang:make_tuple(Arity, DefaultValue, InitList) -> tuple()
3000
3001              Types:
3002
3003                 Arity = arity()
3004                 DefaultValue = term()
3005                 InitList = [{Position :: integer() >= 1, term()}]
3006
3007              Creates  a  tuple  of  size  Arity, where each element has value
3008              DefaultValue, and then fills in values from InitList. Each  list
3009              element in InitList must be a two-tuple, where the first element
3010              is a position in the newly created tuple and the second  element
3011              is  any  term.  If a position occurs more than once in the list,
3012              the term corresponding to the last occurrence is used. Example:
3013
3014              > erlang:make_tuple(5, [], [{2,ignored},{5,zz},{2,aa}]).
3015              {[],aa,[],[],zz}
3016
3017       map_get(Key, Map) -> Value
3018
3019              Types:
3020
3021                 Map = map()
3022                 Key = Value = any()
3023
3024              Returns value Value associated with Key if Map contains Key.
3025
3026              The call fails with a {badmap,Map} exception if  Map  is  not  a
3027              map,  or with a {badkey,Key} exception if no value is associated
3028              with Key.
3029
3030              Example:
3031
3032              > Key = 1337,
3033                Map = #{42 => value_two,1337 => "value one","a" => 1},
3034                map_get(Key,Map).
3035              "value one"
3036
3037              Allowed in guard tests.
3038
3039       map_size(Map) -> integer() >= 0
3040
3041              Types:
3042
3043                 Map = map()
3044
3045              Returns an integer, which is the number of  key-value  pairs  in
3046              Map, for example:
3047
3048              > map_size(#{a=>1, b=>2, c=>3}).
3049              3
3050
3051              Allowed in guard tests.
3052
3053       erlang:match_spec_test(MatchAgainst, MatchSpec, Type) ->
3054                                 TestResult
3055
3056              Types:
3057
3058                 MatchAgainst = [term()] | tuple()
3059                 MatchSpec = term()
3060                 Type = table | trace
3061                 TestResult =
3062                     {ok,   term(),   [return_trace],   [{error   |   warning,
3063                 string()}]} |
3064                     {error, [{error | warning, string()}]}
3065
3066              Tests a match specification used in calls  to  ets:select/2  and
3067              erlang:trace_pattern/3. The function tests both a match specifi‐
3068              cation for "syntactic" correctness and runs the match specifica‐
3069              tion  against  the  object.  If the match specification contains
3070              errors, the tuple {error, Errors} is returned, where Errors is a
3071              list of natural language descriptions of what was wrong with the
3072              match specification.
3073
3074              If Type is table, the object to match against is to be a  tuple.
3075              The  function then returns {ok,Result,[],Warnings}, where Result
3076              is what would have been the result in a real ets:select/2  call,
3077              or  false  if  the match specification does not match the object
3078              tuple.
3079
3080              If Type is trace, the object to match against is to be  a  list.
3081              The function returns {ok, Result, Flags, Warnings}, where Result
3082              is one of the following:
3083
3084                * true if a trace message is to be emitted
3085
3086                * false if a trace message is not to be emitted
3087
3088                * The message term to be appended to the trace message
3089
3090              Flags is a list containing all the trace flags  to  be  enabled,
3091              currently this is only return_trace.
3092
3093              This  is a useful debugging and test tool, especially when writ‐
3094              ing complicated match specifications.
3095
3096              See also ets:test_ms/2.
3097
3098       max(Term1, Term2) -> Maximum
3099
3100              Types:
3101
3102                 Term1 = Term2 = Maximum = term()
3103
3104              Returns the largest of Term1 and Term2. If the terms are  equal,
3105              Term1 is returned.
3106
3107       erlang:md5(Data) -> Digest
3108
3109              Types:
3110
3111                 Data = iodata()
3112                 Digest = binary()
3113
3114              Computes  an  MD5  message digest from Data, where the length of
3115              the digest is 128 bits (16 bytes). Data is a binary or a list of
3116              small integers and binaries.
3117
3118              For more information about MD5, see  RFC 1321 - The MD5 Message-
3119              Digest Algorithm.
3120
3121          Warning:
3122              The MD5 Message-Digest Algorithm  is  not  considered  safe  for
3123              code-signing or software-integrity purposes.
3124
3125
3126       erlang:md5_final(Context) -> Digest
3127
3128              Types:
3129
3130                 Context = Digest = binary()
3131
3132              Finishes  the  update of an MD5 Context and returns the computed
3133              MD5 message digest.
3134
3135       erlang:md5_init() -> Context
3136
3137              Types:
3138
3139                 Context = binary()
3140
3141              Creates an MD5 context, to be used in  the  following  calls  to
3142              md5_update/2.
3143
3144       erlang:md5_update(Context, Data) -> NewContext
3145
3146              Types:
3147
3148                 Context = binary()
3149                 Data = iodata()
3150                 NewContext = binary()
3151
3152              Update an MD5 Context with Data and returns a NewContext.
3153
3154       erlang:memory() -> [{Type, Size}]
3155
3156              Types:
3157
3158                 Type = memory_type()
3159                 Size = integer() >= 0
3160                 memory_type() =
3161                     total | processes | processes_used | system | atom |
3162                     atom_used | binary | code | ets
3163
3164              Returns  a  list with information about memory dynamically allo‐
3165              cated by the Erlang emulator.  Each  list  element  is  a  tuple
3166              {Type,  Size}. The first element Type is an atom describing mem‐
3167              ory type. The second element Size is the memory size in bytes.
3168
3169              Memory types:
3170
3171                total:
3172                  The total amount of memory currently allocated. This is  the
3173                  same as the sum of the memory size for processes and system.
3174
3175                processes:
3176                  The  total  amount  of  memory  currently  allocated for the
3177                  Erlang processes.
3178
3179                processes_used:
3180                  The total amount of memory currently used by the Erlang pro‐
3181                  cesses.  This  is  part of the memory presented as processes
3182                  memory.
3183
3184                system:
3185                  The total amount of memory currently allocated for the  emu‐
3186                  lator  that  is  not directly related to any Erlang process.
3187                  Memory presented as processes is not included in  this  mem‐
3188                  ory. instrument(3) can be used to get a more detailed break‐
3189                  down of what memory is part of this type.
3190
3191                atom:
3192                  The total amount of memory currently  allocated  for  atoms.
3193                  This  memory  is part of the memory presented as system mem‐
3194                  ory.
3195
3196                atom_used:
3197                  The total amount of memory currently used  for  atoms.  This
3198                  memory is part of the memory presented as atom memory.
3199
3200                binary:
3201                  The total amount of memory currently allocated for binaries.
3202                  This memory is part of the memory presented as  system  mem‐
3203                  ory.
3204
3205                code:
3206                  The  total  amount  of memory currently allocated for Erlang
3207                  code. This memory is part of the memory presented as  system
3208                  memory.
3209
3210                ets:
3211                  The  total  amount  of  memory  currently  allocated for ETS
3212                  tables. This memory is part of the memory presented as  sys‐
3213                  tem memory.
3214
3215                low:
3216                  Only on 64-bit halfword emulator. The total amount of memory
3217                  allocated in low memory areas that are restricted to < 4 GB,
3218                  although the system can have more memory.
3219
3220                  Can be removed in a future release of the halfword emulator.
3221
3222                maximum:
3223                  The  maximum total amount of memory allocated since the emu‐
3224                  lator was started. This tuple is only present when the  emu‐
3225                  lator is run with instrumentation.
3226
3227                  For information on how to run the emulator with instrumenta‐
3228                  tion, see instrument(3) and/or erl(1).
3229
3230          Note:
3231              The system value is not complete. Some allocated memory that  is
3232              to be part of this value is not.
3233
3234              When  the emulator is run with instrumentation, the system value
3235              is more accurate, but memory directly allocated for malloc  (and
3236              friends)  is still not part of the system value. Direct calls to
3237              malloc are only done from OS-specific runtime libraries and per‐
3238              haps  from  user-implemented  Erlang drivers that do not use the
3239              memory allocation functions in the driver interface.
3240
3241              As the total value is the sum of processes and system, the error
3242              in system propagates to the total value.
3243
3244              The different amounts of memory that are summed are not gathered
3245              atomically, which introduces an error in the result.
3246
3247
3248              The different values have the following relation to each  other.
3249              Values  beginning  with  an  uppercase letter is not part of the
3250              result.
3251
3252              total      = processes + system
3253              processes  = processes_used + ProcessesNotUsed
3254              system     = atom + binary + code + ets + OtherSystem
3255              atom       = atom_used + AtomNotUsed
3256              RealTotal  = processes + RealSystem
3257              RealSystem = system + MissedSystem
3258
3259              More tuples in the returned  list  can  be  added  in  a  future
3260              release.
3261
3262          Note:
3263              The  total  value  is  supposed to be the total amount of memory
3264              dynamically allocated by the  emulator.  Shared  libraries,  the
3265              code  of  the  emulator  itself, and the emulator stacks are not
3266              supposed to be included. That is, the total value  is  not  sup‐
3267              posed  to  be equal to the total size of all pages mapped to the
3268              emulator.
3269
3270              Also, because of  fragmentation  and  prereservation  of  memory
3271              areas,  the  size  of the memory segments containing the dynami‐
3272              cally allocated memory blocks can be much larger than the  total
3273              size of the dynamically allocated memory blocks.
3274
3275
3276          Note:
3277              As   from   ERTS   5.6.4,   erlang:memory/0  requires  that  all
3278              erts_alloc(3) allocators are enabled (default behavior).
3279
3280
3281              Failure: notsup if an erts_alloc(3) allocator has been disabled.
3282
3283       erlang:memory(Type :: memory_type()) -> integer() >= 0
3284
3285       erlang:memory(TypeList :: [memory_type()]) ->
3286                        [{memory_type(), integer() >= 0}]
3287
3288              Types:
3289
3290                 memory_type() =
3291                     total | processes | processes_used | system | atom |
3292                     atom_used | binary | code | ets
3293
3294              Returns the memory size in bytes allocated for  memory  of  type
3295              Type.  The  argument  can  also  be  specified as a list of mem‐
3296              ory_type() atoms, in which case a corresponding  list  of  {mem‐
3297              ory_type(), Size :: integer >= 0} tuples is returned.
3298
3299          Note:
3300              As   from   ERTS   5.6.4,   erlang:memory/1  requires  that  all
3301              erts_alloc(3) allocators are enabled (default behavior).
3302
3303
3304              Failures:
3305
3306                badarg:
3307                   If Type is not one  of  the  memory  types  listed  in  the
3308                  description of erlang:memory/0.
3309
3310                badarg:
3311                   If maximum is passed as Type and the emulator is not run in
3312                  instrumented mode.
3313
3314                notsup:
3315                   If an erts_alloc(3) allocator has been disabled.
3316
3317              See also erlang:memory/0.
3318
3319       min(Term1, Term2) -> Minimum
3320
3321              Types:
3322
3323                 Term1 = Term2 = Minimum = term()
3324
3325              Returns the smallest of Term1 and Term2. If the terms are equal,
3326              Term1 is returned.
3327
3328       module_loaded(Module) -> boolean()
3329
3330              Types:
3331
3332                 Module = module()
3333
3334              Returns true if the module Module is loaded, otherwise false. It
3335              does not attempt to load the module.
3336
3337          Warning:
3338              This BIF is intended for the code server (see  code(3))  and  is
3339              not to be used elsewhere.
3340
3341
3342       monitor(Type :: process, Item :: monitor_process_identifier()) ->
3343                  MonitorRef
3344
3345       monitor(Type :: port, Item :: monitor_port_identifier()) ->
3346                  MonitorRef
3347
3348       monitor(Type :: time_offset, Item :: clock_service) -> MonitorRef
3349
3350              Types:
3351
3352                 MonitorRef = reference()
3353                 registered_name() = atom()
3354                 registered_process_identifier() =
3355                     registered_name() | {registered_name(), node()}
3356                 monitor_process_identifier() =
3357                     pid() | registered_process_identifier()
3358                 monitor_port_identifier() = port() | registered_name()
3359
3360              Sends a monitor request of type Type to the entity identified by
3361              Item. If the monitored entity does not exist or it changes moni‐
3362              tored state, the caller of monitor/2 is notified by a message on
3363              the following format:
3364
3365              {Tag, MonitorRef, Type, Object, Info}
3366
3367          Note:
3368              The monitor request is an asynchronous signal. That is, it takes
3369              time before the signal reaches its destination.
3370
3371
3372              Type  can  be  one  of  the  following  atoms:  process, port or
3373              time_offset.
3374
3375              A process or port monitor is triggered only once, after that  it
3376              is  removed  from  both  monitoring  process  and  the monitored
3377              entity. Monitors are fired when the monitored  process  or  port
3378              terminates,  does not exist at the moment of creation, or if the
3379              connection to it is lost. If the connection to it is lost, we do
3380              not  know  if it still exists. The monitoring is also turned off
3381              when demonitor/1 is called.
3382
3383              A process or port monitor by name resolves the RegisteredName to
3384              pid()  or  port()  only once at the moment of monitor instantia‐
3385              tion, later changes to the name registration will not affect the
3386              existing monitor.
3387
3388              When a process or port monitor is triggered, a 'DOWN' message is
3389              sent that has the following pattern:
3390
3391              {'DOWN', MonitorRef, Type, Object, Info}
3392
3393              In the monitor message MonitorRef  and  Type  are  the  same  as
3394              described earlier, and:
3395
3396                Object:
3397                  The  monitored entity, which triggered the event. When moni‐
3398                  toring a local process or port, Object will be equal to  the
3399                  pid()  or  port()  that was being monitored. When monitoring
3400                  process or port by name, Object  will  have  format  {Regis‐
3401                  teredName,  Node} where RegisteredName is the name which has
3402                  been used with monitor/2 call and Node is  local  or  remote
3403                  node name (for ports monitored by name, Node is always local
3404                  node name).
3405
3406                Info:
3407                  Either the exit reason of the process,  noproc  (process  or
3408                  port  did  not  exist  at  the time of monitor creation), or
3409                  noconnection (no connection to the node where the  monitored
3410                  process resides).
3411
3412                Monitoring a process:
3413                  Creates  monitor  between  the  current  process and another
3414                  process identified by Item, which can be a pid()  (local  or
3415                  remote),  an atom RegisteredName or a tuple {RegisteredName,
3416                  Node} for a registered process, located elsewhere.
3417
3418            Note:
3419                Before ERTS 10.0 (OTP 21.0), monitoring a process  could  fail
3420                with  badarg  if  the monitored process resided on a primitive
3421                node (such  as  erl_interface  or  jinterface),  where  remote
3422                process monitoring is not implemented.
3423
3424                Now, such a call to monitor will instead succeed and a monitor
3425                is created. But the monitor will only  supervise  the  connec‐
3426                tion.  That is, a {'DOWN', _, process, _, noconnection} is the
3427                only message that may be received, as the primitive node  have
3428                no way of reporting the status of the monitored process.
3429
3430
3431                Monitoring a port:
3432                  Creates monitor between the current process and a port iden‐
3433                  tified by Item, which can be a port() (only local), an  atom
3434                  RegisteredName  or a tuple {RegisteredName, Node} for a reg‐
3435                  istered port, located on this node. Note,  that  attempt  to
3436                  monitor a remote port will result in badarg.
3437
3438                Monitoring a time_offset:
3439                  Monitors  changes  in  time  offset between Erlang monotonic
3440                  time and Erlang system time. One valid Item exists in combi‐
3441                  nation with the time_offset Type, namely the atom clock_ser‐
3442                  vice. Notice that the atom clock_service is not  the  regis‐
3443                  tered  name of a process. In this case it serves as an iden‐
3444                  tifier of the runtime system internal clock service at  cur‐
3445                  rent runtime system instance.
3446
3447                  The  monitor  is  triggered when the time offset is changed.
3448                  This either if the time offset value is changed, or  if  the
3449                  offset is changed from preliminary to final during finaliza‐
3450                  tion of the time offset when the single time  warp  mode  is
3451                  used. When a change from preliminary to final time offset is
3452                  made, the monitor is triggered once  regardless  of  whether
3453                  the time offset value was changed or not.
3454
3455                  If  the  runtime system is in multi time warp mode, the time
3456                  offset is changed when the runtime system detects  that  the
3457                  OS  system  time  has changed. The runtime system does, how‐
3458                  ever, not detect this immediately when  it  occurs.  A  task
3459                  checking  the  time  offset is scheduled to execute at least
3460                  once a minute, so under  normal  operation  this  is  to  be
3461                  detected  within a minute, but during heavy load it can take
3462                  longer time.
3463
3464                  The monitor is not automatically removed after it  has  been
3465                  triggered.  That  is,  repeated  changes  of the time offset
3466                  trigger the monitor repeatedly.
3467
3468                  When the monitor is triggered a 'CHANGE' message is sent  to
3469                  the monitoring process. A 'CHANGE' message has the following
3470                  pattern:
3471
3472                {'CHANGE', MonitorRef, Type, Item, NewTimeOffset}
3473
3474                  where MonitorRef, Type, and Item are the same  as  described
3475                  above, and NewTimeOffset is the new time offset.
3476
3477                  When  the 'CHANGE' message has been received you are guaran‐
3478                  teed not to  retrieve  the  old  time  offset  when  calling
3479                  erlang:time_offset(). Notice that you can observe the change
3480                  of the time offset when calling erlang:time_offset()  before
3481                  you get the 'CHANGE' message.
3482
3483              Making  several calls to monitor/2 for the same Item and/or Type
3484              is not an error; it results in as  many  independent  monitoring
3485              instances.
3486
3487              The  monitor  functionality is expected to be extended. That is,
3488              other Types and Items are expected to be supported in  a  future
3489              release.
3490
3491          Note:
3492              If or when monitor/2 is extended, other possible values for Tag,
3493              Object, and Info in the monitor message will be introduced.
3494
3495
3496       monitor_node(Node, Flag) -> true
3497
3498              Types:
3499
3500                 Node = node()
3501                 Flag = boolean()
3502
3503              Monitor the status of the node Node. If Flag is true, monitoring
3504              is turned on. If Flag is false, monitoring is turned off.
3505
3506              Making  several  calls  to monitor_node(Node, true) for the same
3507              Node is not an error; it results in as many independent monitor‐
3508              ing instances.
3509
3510              If Node fails or does not exist, the message {nodedown, Node} is
3511              delivered to the process. If a process has  made  two  calls  to
3512              monitor_node(Node,  true) and Node terminates, two nodedown mes‐
3513              sages are delivered to the process. If there is no connection to
3514              Node,  an  attempt is made to create one. If this fails, a node‐
3515              down message is delivered.
3516
3517              Nodes connected through hidden connections can be  monitored  as
3518              any other nodes.
3519
3520              Failure: badarg if the local node is not alive.
3521
3522       erlang:monitor_node(Node, Flag, Options) -> true
3523
3524              Types:
3525
3526                 Node = node()
3527                 Flag = boolean()
3528                 Options = [Option]
3529                 Option = allow_passive_connect
3530
3531              Behaves  as monitor_node/2 except that it allows an extra option
3532              to  be  specified,  namely  allow_passive_connect.  This  option
3533              allows  the  BIF  to wait the normal network connection time-out
3534              for the monitored node to connect itself, even if it  cannot  be
3535              actively  connected from this node (that is, it is blocked). The
3536              state where this can be useful can only be achieved by using the
3537              Kernel  option  dist_auto_connect  once.  If  that option is not
3538              used, option allow_passive_connect has no effect.
3539
3540          Note:
3541              Option allow_passive_connect is used internally  and  is  seldom
3542              needed in applications where the network topology and the Kernel
3543              options in effect are known in advance.
3544
3545
3546              Failure: badarg if the local node is not  alive  or  the  option
3547              list is malformed.
3548
3549       erlang:monotonic_time() -> integer()
3550
3551              Returns  the  current Erlang monotonic time in native time unit.
3552              This is a monotonically increasing time since  some  unspecified
3553              point in time.
3554
3555          Note:
3556              This  is  a   monotonically increasing time, but not a  strictly
3557              monotonically increasing time. That  is,  consecutive  calls  to
3558              erlang:monotonic_time/0 can produce the same result.
3559
3560              Different  runtime  system instances will use different unspeci‐
3561              fied points in time as base for their Erlang  monotonic  clocks.
3562              That  is, it is pointless comparing monotonic times from differ‐
3563              ent runtime system instances. Different runtime system instances
3564              can also place this unspecified point in time different relative
3565              runtime system start. It can be placed in the  future  (time  at
3566              start  is  a negative value), the past (time at start is a posi‐
3567              tive value), or the runtime  system  start  (time  at  start  is
3568              zero).  The  monotonic  time  at  runtime  system  start  can be
3569              retrieved by calling erlang:system_info(start_time).
3570
3571
3572       erlang:monotonic_time(Unit) -> integer()
3573
3574              Types:
3575
3576                 Unit = time_unit()
3577
3578              Returns the current Erlang monotonic  time  converted  into  the
3579              Unit passed as argument.
3580
3581              Same     as     calling    erlang:convert_time_unit(erlang:mono‐
3582              tonic_time(), native, Unit), however optimized for commonly used
3583              Units.
3584
3585       erlang:nif_error(Reason) -> no_return()
3586
3587              Types:
3588
3589                 Reason = term()
3590
3591              Works  exactly  like  error/1, but Dialyzer thinks that this BIF
3592              will return an arbitrary term. When used in a stub function  for
3593              a  NIF  to  generate  an  exception  when the NIF library is not
3594              loaded, Dialyzer does not generate false warnings.
3595
3596       erlang:nif_error(Reason, Args) -> no_return()
3597
3598              Types:
3599
3600                 Reason = term()
3601                 Args = [term()]
3602
3603              Works exactly like error/2, but Dialyzer thinks  that  this  BIF
3604              will  return an arbitrary term. When used in a stub function for
3605              a NIF to generate an exception  when  the  NIF  library  is  not
3606              loaded, Dialyzer does not generate false warnings.
3607
3608       node() -> Node
3609
3610              Types:
3611
3612                 Node = node()
3613
3614              Returns  the  name  of the local node. If the node is not alive,
3615              nonode@nohost is returned instead.
3616
3617              Allowed in guard tests.
3618
3619       node(Arg) -> Node
3620
3621              Types:
3622
3623                 Arg = pid() | port() | reference()
3624                 Node = node()
3625
3626              Returns the node where Arg originates.  Arg  can  be  a  process
3627              identifier,  a  reference,  or  a port. If the local node is not
3628              alive, nonode@nohost is returned.
3629
3630              Allowed in guard tests.
3631
3632       nodes() -> Nodes
3633
3634              Types:
3635
3636                 Nodes = [node()]
3637
3638              Returns a list of all visible nodes in the  system,  except  the
3639              local node. Same as nodes(visible).
3640
3641       nodes(Arg) -> Nodes
3642
3643              Types:
3644
3645                 Arg = NodeType | [NodeType]
3646                 NodeType = visible | hidden | connected | this | known
3647                 Nodes = [node()]
3648
3649              Returns a list of nodes according to the argument specified. The
3650              returned result, when the argument is a list,  is  the  list  of
3651              nodes satisfying the disjunction(s) of the list elements.
3652
3653              NodeTypes:
3654
3655                visible:
3656                  Nodes connected to this node through normal connections.
3657
3658                hidden:
3659                  Nodes connected to this node through hidden connections.
3660
3661                connected:
3662                  All nodes connected to this node.
3663
3664                this:
3665                  This node.
3666
3667                known:
3668                  Nodes  that are known to this node. That is, connected nodes
3669                  and nodes referred to by process identifiers,  port  identi‐
3670                  fiers, and references located on this node. The set of known
3671                  nodes is garbage collected. Notice that this garbage collec‐
3672                  tion  can  be delayed. For more information, see erlang:sys‐
3673                  tem_info(delayed_node_table_gc).
3674
3675              Some equalities:  [node()]  =  nodes(this),  nodes(connected)  =
3676              nodes([visible, hidden]), and nodes() = nodes(visible).
3677
3678       now() -> Timestamp
3679
3680              Types:
3681
3682                 Timestamp = timestamp()
3683                 timestamp() =
3684                     {MegaSecs :: integer() >= 0,
3685                      Secs :: integer() >= 0,
3686                      MicroSecs :: integer() >= 0}
3687
3688          Warning:
3689              This function is deprecated. Do not use it.
3690
3691              For  more  information,  see section Time and Time Correction in
3692              the  User's  Guide.  Specifically,  section   Dos   and   Dont's
3693              describes what to use instead of erlang:now/0.
3694
3695
3696              Returns  the  tuple  {MegaSecs,  Secs,  MicroSecs}, which is the
3697              elapsed time since 00:00 GMT, January 1, 1970  (zero  hour),  if
3698              provided  by  the  underlying  OS. Otherwise some other point in
3699              time is chosen. It is also guaranteed that the  following  calls
3700              to  this  BIF  return continuously increasing values. Hence, the
3701              return value from erlang:now/0 can be used  to  generate  unique
3702              time  stamps. If it is called in a tight loop on a fast machine,
3703              the time of the node can become skewed.
3704
3705              Can only be used to check the local time of day if the time-zone
3706              information of the underlying OS is properly configured.
3707
3708       open_port(PortName, PortSettings) -> port()
3709
3710              Types:
3711
3712                 PortName =
3713                     {spawn, Command :: string() | binary()} |
3714                     {spawn_driver, Command :: string() | binary()} |
3715                     {spawn_executable, FileName :: file:name_all()} |
3716                     {fd, In :: integer() >= 0, Out :: integer() >= 0}
3717                 PortSettings = [Opt]
3718                 Opt =
3719                     {packet, N :: 1 | 2 | 4} |
3720                     stream |
3721                     {line, L :: integer() >= 0} |
3722                     {cd, Dir :: string() | binary()} |
3723                     {env,
3724                      Env ::
3725                          [{Name :: os:env_var_name(),
3726                            Val :: os:env_var_value() | false}]} |
3727                     {args, [string() | binary()]} |
3728                     {arg0, string() | binary()} |
3729                     exit_status  | use_stdio | nouse_stdio | stderr_to_stdout
3730                 |
3731                     in | out | binary | eof |
3732                     {parallelism, Boolean :: boolean()} |
3733                     hide |
3734                     {busy_limits_port,
3735                      {integer() >= 0, integer() >= 0} | disabled} |
3736                     {busy_limits_msgq,
3737                      {integer() >= 0, integer() >= 0} | disabled}
3738
3739              Returns a port identifier as the result of opening a new  Erlang
3740              port. A port can be seen as an external Erlang process.
3741
3742              The  name of the executable as well as the arguments specifed in
3743              cd, env, args, and arg0 are subject to Unicode filename transla‐
3744              tion if the system is running in Unicode filename mode. To avoid
3745              translation or to force, for  example  UTF-8,  supply  the  exe‐
3746              cutable  and/or  arguments  as a binary in the correct encoding.
3747              For   details,   see   the   module   file(3),   the    function
3748              file:native_name_encoding/0  in Kernel, and the Using Unicode in
3749              Erlang User's Guide.
3750
3751          Note:
3752              The characters in the name (if specified as a list) can only  be
3753              >  255 if the Erlang virtual machine is started in Unicode file‐
3754              name translation mode. Otherwise the name of the  executable  is
3755              limited to the ISO Latin-1 character set.
3756
3757
3758              PortNames:
3759
3760                {spawn, Command}:
3761                  Starts  an  external  program.  Command  is  the name of the
3762                  external program to be run. Command runs outside the  Erlang
3763                  work  space unless an Erlang driver with the name Command is
3764                  found. If found, that driver is started. A  driver  runs  in
3765                  the  Erlang  work  space, which means that it is linked with
3766                  the Erlang runtime system.
3767
3768                  For external programs, PATH is searched  (or  an  equivalent
3769                  method  is used to find programs, depending on the OS). This
3770                  is done by invoking the  shell  on  certain  platforms.  The
3771                  first  space-separated token of the command is considered as
3772                  the name of the executable (or driver).  This  (among  other
3773                  things)  makes  this  option unsuitable for running programs
3774                  with spaces in filenames or directory names.  If  spaces  in
3775                  executable  filenames  are  desired,  use {spawn_executable,
3776                  Command} instead.
3777
3778                {spawn_driver, Command}:
3779                  Works like {spawn, Command}, but demands the  first  (space-
3780                  separated)  token  of the command to be the name of a loaded
3781                  driver. If no driver with that  name  is  loaded,  a  badarg
3782                  error is raised.
3783
3784                {spawn_executable, FileName}:
3785                  Works  like  {spawn,  FileName}, but only runs external exe‐
3786                  cutables. FileName in its whole is used as the name  of  the
3787                  executable,  including  any  spaces.  If arguments are to be
3788                  passed, the PortSettings args and arg0 can be used.
3789
3790                  The shell is usually not invoked to start the program, it is
3791                  executed  directly. PATH (or equivalent) is not searched. To
3792                  find a program in PATH to execute, use os:find_executable/1.
3793
3794                  Only if a shell script or .bat file is executed, the  appro‐
3795                  priate  command interpreter is invoked implicitly, but there
3796                  is still no  command-argument  expansion  or  implicit  PATH
3797                  search.
3798
3799                  If  FileName  cannot  be  run, an error exception is raised,
3800                  with the POSIX error code as the reason.  The  error  reason
3801                  can differ between OSs. Typically the error enoent is raised
3802                  when an attempt is made to run a program that is  not  found
3803                  and  eacces  is  raised  when the specified file is not exe‐
3804                  cutable.
3805
3806                {fd, In, Out}:
3807                  Allows an Erlang process to access any currently opened file
3808                  descriptors  used  by  Erlang. The file descriptor In can be
3809                  used for standard input, and the  file  descriptor  Out  for
3810                  standard  output. It is only used for various servers in the
3811                  Erlang OS (shell and user). Hence, its use is limited.
3812
3813              PortSettings is a list of settings for the port. The valid  set‐
3814              tings are as follows:
3815
3816                {packet, N}:
3817                  Messages are preceded by their length, sent in N bytes, with
3818                  the most significant byte first. The valid values for N  are
3819                  1, 2, and 4.
3820
3821                stream:
3822                  Output  messages  are  sent  without packet lengths. A user-
3823                  defined protocol must be used between the Erlang process and
3824                  the external object.
3825
3826                {line, L}:
3827                  Messages  are  delivered  on  a  per  line  basis. Each line
3828                  (delimited by the OS-dependent newline sequence)  is  deliv‐
3829                  ered  in a single message. The message data format is {Flag,
3830                  Line}, where Flag is eol or noeol,  and  Line  is  the  data
3831                  delivered (without the newline sequence).
3832
3833                  L  specifies  the maximum line length in bytes. Lines longer
3834                  than this are delivered in more than one message, with  Flag
3835                  set to noeol for all but the last message. If end of file is
3836                  encountered anywhere else than immediately following a  new‐
3837                  line sequence, the last line is also delivered with Flag set
3838                  to noeol. Otherwise lines are delivered  with  Flag  set  to
3839                  eol.
3840
3841                  The  {packet,  N} and {line, L} settings are mutually exclu‐
3842                  sive.
3843
3844                {cd, Dir}:
3845                  Only valid for {spawn, Command} and {spawn_executable, File‐
3846                  Name}.  The external program starts using Dir as its working
3847                  directory. Dir must be a string.
3848
3849                {env, Env}:
3850                  Types:
3851                  Name = os:env_var_name()
3852                  Val = os:env_var_value() | false
3853                  Env = [{Name, Val}]
3854
3855                  Only valid  for  {spawn,  Command},  and  {spawn_executable,
3856                  FileName}.   The  environment  of  the  started  process  is
3857                  extended using the environment specifications in Env.
3858
3859                  Env is to be a list of tuples {Name, Val}, where Name is the
3860                  name  of an environment variable, and Val is the value it is
3861                  to have in the spawned port process. Both Name and Val  must
3862                  be  strings.  The  one exception is Val being the atom false
3863                  (in analogy with os:getenv/1, which removes the  environment
3864                  variable.
3865
3866                  For  information about encoding requirements, see documenta‐
3867                  tion of the types for Name and Val.
3868
3869                {args, [ string() | binary() ]}:
3870                  Only valid for {spawn_executable,  FileName}  and  specifies
3871                  arguments to the executable. Each argument is specified as a
3872                  separate string and (on Unix) eventually ends up as one ele‐
3873                  ment each in the argument vector. On other platforms, a sim‐
3874                  ilar behavior is mimicked.
3875
3876                  The arguments are not expanded by the shell before they  are
3877                  supplied  to  the  executable.  Most notably this means that
3878                  file wildcard expansion does not occur. To expand  wildcards
3879                  for  the arguments, use filelib:wildcard/1. Notice that even
3880                  if the program is a Unix  shell  script,  meaning  that  the
3881                  shell  ultimately  is  invoked,  wildcard expansion does not
3882                  occur, and the script is provided with the  untouched  argu‐
3883                  ments.  On  Windows,  wildcard expansion is always up to the
3884                  program itself, therefore this is not an issue.
3885
3886                  The executable name (also known as argv[0])  is  not  to  be
3887                  specified  in this list. The proper executable name is auto‐
3888                  matically used as argv[0], where applicable.
3889
3890                  If you explicitly want to set the program name in the  argu‐
3891                  ment vector, option arg0 can be used.
3892
3893                {arg0, string() | binary()}:
3894                  Only  valid  for {spawn_executable, FileName} and explicitly
3895                  specifies the program name argument  when  running  an  exe‐
3896                  cutable.  This  can  in  some circumstances, on some OSs, be
3897                  desirable. How the program responds to this is  highly  sys‐
3898                  tem-dependent and no specific effect is guaranteed.
3899
3900                exit_status:
3901                  Only  valid for {spawn, Command}, where Command refers to an
3902                  external program, and for {spawn_executable, FileName}.
3903
3904                  When the external process connected to  the  port  exits,  a
3905                  message  of  the form {Port,{exit_status,Status}} is sent to
3906                  the connected process, where Status is the  exit  status  of
3907                  the  external  process.  If  the program aborts on Unix, the
3908                  same convention is used as the shells do (that is,  128+sig‐
3909                  nal).
3910
3911                  If  option  eof  is  specified  also,  the  messages eof and
3912                  exit_status appear in an unspecified order.
3913
3914                  If the port  program  closes  its  stdout  without  exiting,
3915                  option exit_status does not work.
3916
3917                use_stdio:
3918                  Only valid for {spawn, Command} and {spawn_executable, File‐
3919                  Name}.  It  allows  the  standard  input  and  output  (file
3920                  descriptors  0 and 1) of the spawned (Unix) process for com‐
3921                  munication with Erlang.
3922
3923                nouse_stdio:
3924                  The opposite of use_stdio. It uses file descriptors 3 and  4
3925                  for communication with Erlang.
3926
3927                stderr_to_stdout:
3928                  Affects  ports  to  external  programs. The executed program
3929                  gets its standard error file redirected to its standard out‐
3930                  put  file.  stderr_to_stdout  and  nouse_stdio  are mutually
3931                  exclusive.
3932
3933                overlapped_io:
3934                  Affects ports to external  programs  on  Windows  only.  The
3935                  standard  input and standard output handles of the port pro‐
3936                  gram are, if this  option  is  supplied,  opened  with  flag
3937                  FILE_FLAG_OVERLAPPED,  so  that  the  port  program can (and
3938                  must) do overlapped I/O on its standard handles. This is not
3939                  normally the case for simple port programs, but an option of
3940                  value for the experienced Windows programmer. On  all  other
3941                  platforms, this option is silently discarded.
3942
3943                in:
3944                  The port can only be used for input.
3945
3946                out:
3947                  The port can only be used for output.
3948
3949                binary:
3950                  All  I/O  from the port is binary data objects as opposed to
3951                  lists of bytes.
3952
3953                eof:
3954                  The port is not closed at the end of the file and  does  not
3955                  produce  an  exit  signal.  Instead,  it  remains open and a
3956                  {Port, eof} message is sent to the process holding the port.
3957
3958                hide:
3959                  When running on Windows, suppresses creation of a  new  con‐
3960                  sole window when spawning the port program. (This option has
3961                  no effect on other platforms.)
3962
3963                {parallelism, Boolean}:
3964
3965
3966                  Sets scheduler hint for port parallelism. If  set  to  true,
3967                  the  virtual machine schedules port tasks; when doing so, it
3968                  improves parallelism in the system. If  set  to  false,  the
3969                  virtual  machine  tries  to  perform port tasks immediately,
3970                  improving latency at the expense of parallelism. The default
3971                  can  be  set at system startup by passing command-line argu‐
3972                  ment +spp to erl(1).
3973
3974                {busy_limits_port, {Low, High} | disabled}:
3975                  Sets limits that will be used for controlling the busy state
3976                  of the port.
3977
3978                  When  the  ports  internal  output queue size becomes larger
3979                  than or equal to High bytes, it enters the busy state.  When
3980                  it  becomes  less  than  Low bytes it leaves the busy state.
3981                  When the port is in the busy state, processes  sending  com‐
3982                  mands to it will be suspended until the port leaves the busy
3983                  state. Commands are in this context either  Port  !  {Owner,
3984                  {command, Data}} or port_command/[2,3].
3985
3986                  The  Low limit is automatically adjusted to the same as High
3987                  if it is set larger then High. Valid range of values for Low
3988                  and High is [1, (1 bsl (8*erlang:system_info(wordsize)))-2].
3989                  If the atom disabled is passed, the port  will  never  enter
3990                  the busy state.
3991
3992                  The defaults are Low = 4096 and High = 8192.
3993
3994                  Note  that  this  option is only valid when spawning an exe‐
3995                  cutable (port program) by opening the spawn driver and  when
3996                  opening the fd driver. This option will cause a failure with
3997                  a badarg exception when opening other drivers.
3998
3999                {busy_limits_msgq, {Low, High} | disabled}:
4000                  Sets limits that will be used for controlling the busy state
4001                  of the port message queue.
4002
4003                  When  the  ports  message  queue size becomes larger than or
4004                  equal to High bytes  it  enters  the  busy  state.  When  it
4005                  becomes  less  than Low bytes it leaves the busy state. When
4006                  the port message queue is in the busy state, processes send‐
4007                  ing  commands to it will be suspended until the port message
4008                  queue leaves the busy state. Commands are  in  this  context
4009                  either   Port   !  {Owner,  {command,  Data}}  or  port_com‐
4010                  mand/[2,3].
4011
4012                  The Low limit is automatically adjusted to the same as  High
4013                  if it is set larger then High. Valid range of values for Low
4014                  and High is [1, (1 bsl (8*erlang:system_info(wordsize)))-2].
4015                  If  the atom disabled is passed, the port message queue will
4016                  never enter the busy state.
4017
4018                  Note that if the driver statically has disabled the  use  of
4019                  this  feature,  a  failure  with  a badarg exception will be
4020                  raised unless this option also is  set  to  disable  or  not
4021                  passed at all.
4022
4023                  The  defaults  are  Low  =  4096  and High = 8192 unless the
4024                  driver itself does modifications of these values.
4025
4026                  Note that the driver might fail if it also adjust these lim‐
4027                  its by itself and you have disabled this feature.
4028
4029                  The  spawn driver (used when spawning an executable) and the
4030                  fd driver do not disable this  feature  and  do  not  adjust
4031                  these limits by themselves.
4032
4033                  For     more     information     see    the    documentation
4034                  erl_drv_busy_msgq_limits().
4035
4036              Default is stream for all port types and use_stdio  for  spawned
4037              ports.
4038
4039              Failure:  if  the  port  cannot  be  opened,  the exit reason is
4040              badarg, system_limit, or the POSIX error code that most  closely
4041              describes the error, or einval if no POSIX code is appropriate:
4042
4043                badarg:
4044                  Bad input arguments to open_port.
4045
4046                system_limit:
4047                  All available ports in the Erlang emulator are in use.
4048
4049                enomem:
4050                  Not enough memory to create the port.
4051
4052                eagain:
4053                  No more available OS processes.
4054
4055                enametoolong:
4056                  Too long external command.
4057
4058                emfile:
4059                  No  more available file descriptors (for the OS process that
4060                  the Erlang emulator runs in).
4061
4062                enfile:
4063                  Full file table (for the entire OS).
4064
4065                eacces:
4066                  Command specified in {spawn_executable,  Command}  does  not
4067                  point out an executable file.
4068
4069                enoent:
4070                  FileName  specified in {spawn_executable, FileName} does not
4071                  point out an existing file.
4072
4073              During use of a port opened using {spawn, Name},  {spawn_driver,
4074              Name},  or {spawn_executable, Name}, errors arising when sending
4075              messages to it are reported to the owning process using  signals
4076              of  the  form {'EXIT', Port, PosixCode}. For the possible values
4077              of PosixCode, see file(3).
4078
4079              The maximum number of ports that can be open at  the  same  time
4080              can be configured by passing command-line flag +Q to erl(1).
4081
4082       erlang:phash(Term, Range) -> Hash
4083
4084              Types:
4085
4086                 Term = term()
4087                 Range = Hash = integer() >= 1
4088                   Range = 1..2^32, Hash = 1..Range
4089
4090              Portable  hash  function  that  gives the same hash for the same
4091              Erlang term regardless of machine architecture and ERTS  version
4092              (the BIF was introduced in ERTS 4.9.1.1). The function returns a
4093              hash value for Term within the range 1..Range. The maximum value
4094              for Range is 2^32.
4095
4096       erlang:phash2(Term) -> Hash
4097
4098       erlang:phash2(Term, Range) -> Hash
4099
4100              Types:
4101
4102                 Term = term()
4103                 Range = integer() >= 1
4104                   1..2^32
4105                 Hash = integer() >= 0
4106                   0..Range-1
4107
4108              Portable  hash  function  that  gives the same hash for the same
4109              Erlang term regardless of machine architecture and ERTS  version
4110              (the  BIF  was  introduced  in ERTS 5.2). The function returns a
4111              hash value for Term within the  range  0..Range-1.  The  maximum
4112              value for Range is 2^32. When without argument Range, a value in
4113              the range 0..2^27-1 is returned.
4114
4115              This BIF is always to be used for hashing terms. It  distributes
4116              small integers better than phash/2, and it is faster for bignums
4117              and binaries.
4118
4119              Notice that the range 0..Range-1 is different from the range  of
4120              phash/2, which is 1..Range.
4121
4122       pid_to_list(Pid) -> string()
4123
4124              Types:
4125
4126                 Pid = pid()
4127
4128              Returns  a  string  corresponding  to the text representation of
4129              Pid.
4130
4131       erlang:port_call(Port, Operation, Data) -> term()
4132
4133              Types:
4134
4135                 Port = port() | atom()
4136                 Operation = integer()
4137                 Data = term()
4138
4139              Performs a synchronous call to a port. The meaning of  Operation
4140              and  Data  depends on the port, that is, on the port driver. Not
4141              all port drivers support this feature.
4142
4143              Port is a port identifier, referring to a driver.
4144
4145              Operation is an integer, which is passed on to the driver.
4146
4147              Data is any Erlang term. This data is converted to  binary  term
4148              format and sent to the port.
4149
4150              Returns a term from the driver. The meaning of the returned data
4151              also depends on the port driver.
4152
4153              Failures:
4154
4155                badarg:
4156                   If Port is not an identifier of an open port, or the regis‐
4157                  tered  name of an open port. If the calling process was pre‐
4158                  viously linked to the closed port, identified by  Port,  the
4159                  exit  signal  from  the  port  is guaranteed to be delivered
4160                  before this badarg exception occurs.
4161
4162                badarg:
4163                   If Operation does not fit in a 32-bit integer.
4164
4165                badarg:
4166                   If the port driver does  not  support  synchronous  control
4167                  operations.
4168
4169                badarg:
4170                  If the port driver so decides for any reason (probably some‐
4171                  thing wrong with Operation or Data).
4172
4173            Warning:
4174                Do not call port_call with  an  unknown  Port  identifier  and
4175                expect  badarg  exception.  Any undefined behavior is possible
4176                (including node crash) depending on how the port driver inter‐
4177                prets the supplied arguments.
4178
4179
4180       port_close(Port) -> true
4181
4182              Types:
4183
4184                 Port = port() | atom()
4185
4186              Closes  an open port. Roughly the same as Port ! {self(), close}
4187              except for the error behavior (see  below),  being  synchronous,
4188              and  that  the  port  does  not  reply  with {Port, closed}. Any
4189              process can close a port with port_close/1, not  only  the  port
4190              owner  (the connected process). If the calling process is linked
4191              to the port identified by Port, the exit signal from the port is
4192              guaranteed to be delivered before port_close/1 returns.
4193
4194              For comparison: Port ! {self(), close} only fails with badarg if
4195              Port does not refer to a port or a process. If Port is a  closed
4196              port,  nothing  happens. If Port is an open port and the calling
4197              process is the port owner, the port replies with {Port,  closed}
4198              when  all  buffers have been flushed and the port really closes.
4199              If the calling process is not the port  owner,  the  port  owner
4200              fails with badsig.
4201
4202              Notice  that  any  process  can  close a port using Port ! {Por‐
4203              tOwner, close} as if it itself was the port owner, but the reply
4204              always goes to the port owner.
4205
4206              As from Erlang/OTP R16, Port ! {PortOwner, close} is truly asyn‐
4207              chronous. Notice that this operation has always been  documented
4208              as  an  asynchronous operation, while the underlying implementa‐
4209              tion has been synchronous. port_close/1 is however  still  fully
4210              synchronous because of its error behavior.
4211
4212              Failure: badarg if Port is not an identifier of an open port, or
4213              the registered name of an open port. If the calling process  was
4214              previously  linked  to  the closed port, identified by Port, the
4215              exit signal from the port is guaranteed to be  delivered  before
4216              this badarg exception occurs.
4217
4218       port_command(Port, Data) -> true
4219
4220              Types:
4221
4222                 Port = port() | atom()
4223                 Data = iodata()
4224
4225              Sends  data  to  a  port.  Same  as Port ! {PortOwner, {command,
4226              Data}} except for the error behavior and being synchronous  (see
4227              below). Any process can send data to a port with port_command/2,
4228              not only the port owner (the connected process).
4229
4230              For comparison: Port ! {PortOwner, {command, Data}}  only  fails
4231              with  badarg  if  Port does not refer to a port or a process. If
4232              Port is a closed port, the data  message  disappears  without  a
4233              sound.  If  Port is open and the calling process is not the port
4234              owner, the port owner fails with badsig. The  port  owner  fails
4235              with badsig also if Data is an invalid I/O list.
4236
4237              Notice  that  any  process can send to a port using Port ! {Por‐
4238              tOwner, {command, Data}} as if it itself was the port owner.
4239
4240              If the port is busy, the calling process is suspended until  the
4241              port is not busy any more.
4242
4243              As  from  Erlang/OTP R16, Port ! {PortOwner, {command, Data}} is
4244              truly asynchronous. Notice that this operation has  always  been
4245              documented  as  an  asynchronous operation, while the underlying
4246              implementation has been synchronous. port_command/2  is  however
4247              still fully synchronous because of its error behavior.
4248
4249              Failures:
4250
4251                badarg:
4252                  If  Port is not an identifier of an open port, or the regis‐
4253                  tered name of an open port. If the calling process was  pre‐
4254                  viously  linked  to the closed port, identified by Port, the
4255                  exit signal from the port  is  guaranteed  to  be  delivered
4256                  before this badarg exception occurs.
4257
4258                badarg:
4259                  If Data is an invalid I/O list.
4260
4261          Warning:
4262              Do  not  send data to an unknown port. Any undefined behavior is
4263              possible (including node crash) depending on how the port driver
4264              interprets the data.
4265
4266
4267       port_command(Port, Data, OptionList) -> boolean()
4268
4269              Types:
4270
4271                 Port = port() | atom()
4272                 Data = iodata()
4273                 Option = force | nosuspend
4274                 OptionList = [Option]
4275
4276              Sends  data  to  a  port.  port_command(Port,  Data,  []) equals
4277              port_command(Port, Data).
4278
4279              If the port command is aborted,  false  is  returned,  otherwise
4280              true.
4281
4282              If  the port is busy, the calling process is suspended until the
4283              port is not busy anymore.
4284
4285              Options:
4286
4287                force:
4288                  The calling process is not suspended if the  port  is  busy,
4289                  instead  the  port command is forced through. The call fails
4290                  with a notsup exception if the driver of the port  does  not
4291                  support   this.   For  more  information,  see  driver  flag
4292                  ERL_DRV_FLAG_SOFT_BUSY.
4293
4294                nosuspend:
4295                  The calling process is not suspended if the  port  is  busy,
4296                  instead the port command is aborted and false is returned.
4297
4298          Note:
4299              More options can be added in a future release.
4300
4301
4302              Failures:
4303
4304                badarg:
4305                   If Port is not an identifier of an open port, or the regis‐
4306                  tered name of an open port. If the calling process was  pre‐
4307                  viously  linked  to the closed port, identified by Port, the
4308                  exit signal from the port  is  guaranteed  to  be  delivered
4309                  before this badarg exception occurs.
4310
4311                badarg:
4312                   If Data is an invalid I/O list.
4313
4314                badarg:
4315                   If OptionList is an invalid option list.
4316
4317                notsup:
4318                   If option force has been passed, but the driver of the port
4319                  does not allow forcing through a busy port.
4320
4321          Warning:
4322              Do not send data to an unknown port. Any undefined  behavior  is
4323              possible (including node crash) depending on how the port driver
4324              interprets the data.
4325
4326
4327       port_connect(Port, Pid) -> true
4328
4329              Types:
4330
4331                 Port = port() | atom()
4332                 Pid = pid()
4333
4334              Sets the port owner (the connected port)  to  Pid.  Roughly  the
4335              same as Port ! {Owner, {connect, Pid}} except for the following:
4336
4337                * The error behavior differs, see below.
4338
4339                * The port does not reply with {Port,connected}.
4340
4341                * port_connect/1 is synchronous, see below.
4342
4343                * The new port owner gets linked to the port.
4344
4345              The  old  port  owner  stays  linked  to  the port and must call
4346              unlink(Port) if this is not desired. Any  process  can  set  the
4347              port owner to be any process with port_connect/2.
4348
4349              For  comparison: Port ! {self(), {connect, Pid}} only fails with
4350              badarg if Port does not refer to a port or a process. If Port is
4351              a  closed port, nothing happens. If Port is an open port and the
4352              calling process is the port owner, the port replies with  {Port,
4353              connected} to the old port owner. Notice that the old port owner
4354              is still linked to the port, while the new is not. If Port is an
4355              open  port  and  the  calling process is not the port owner, the
4356              port owner fails with badsig. The port owner fails  with  badsig
4357              also if Pid is not an existing local process identifier.
4358
4359              Notice  that  any  process  can  set the port owner using Port !
4360              {PortOwner, {connect, Pid}} as if it itself was the port  owner,
4361              but the reply always goes to the port owner.
4362
4363              As  from  Erlang/OTP  R16, Port ! {PortOwner, {connect, Pid}} is
4364              truly asynchronous. Notice that this operation has  always  been
4365              documented  as  an  asynchronous operation, while the underlying
4366              implementation has been synchronous. port_connect/2  is  however
4367              still fully synchronous because of its error behavior.
4368
4369              Failures:
4370
4371                badarg:
4372                   If Port is not an identifier of an open port, or the regis‐
4373                  tered name of an open port. If the calling process was  pre‐
4374                  viously  linked  to the closed port, identified by Port, the
4375                  exit signal from the port  is  guaranteed  to  be  delivered
4376                  before this badarg exception occurs.
4377
4378                badarg:
4379                  If  the  process  identified by Pid is not an existing local
4380                  process.
4381
4382       port_control(Port, Operation, Data) -> iodata() | binary()
4383
4384              Types:
4385
4386                 Port = port() | atom()
4387                 Operation = integer()
4388                 Data = iodata()
4389
4390              Performs a synchronous control operation on a port. The  meaning
4391              of  Operation and Data depends on the port, that is, on the port
4392              driver. Not all port drivers support this control feature.
4393
4394              Returns a list of integers in the range  0..255,  or  a  binary,
4395              depending  on  the port driver. The meaning of the returned data
4396              also depends on the port driver.
4397
4398              Failures:
4399
4400                badarg:
4401                   If Port is not an open port or the registered  name  of  an
4402                  open port.
4403
4404                badarg:
4405                   If Operation cannot fit in a 32-bit integer.
4406
4407                badarg:
4408                   If  the  port  driver  does not support synchronous control
4409                  operations.
4410
4411                badarg:
4412                   If the port driver so  decides  for  any  reason  (probably
4413                  something wrong with Operation or Data).
4414
4415            Warning:
4416                Do not call port_control/3 with an unknown Port identifier and
4417                expect badarg exception. Any undefined  behavior  is  possible
4418                (including node crash) depending on how the port driver inter‐
4419                prets the supplied arguments.
4420
4421
4422       erlang:port_info(Port) -> Result
4423
4424              Types:
4425
4426                 Port = port() | atom()
4427                 ResultItem =
4428                     {registered_name, RegisteredName :: atom()} |
4429                     {id, Index :: integer() >= 0} |
4430                     {connected, Pid :: pid()} |
4431                     {links, Pids :: [pid()]} |
4432                     {name, String :: string()} |
4433                     {input, Bytes :: integer() >= 0} |
4434                     {output, Bytes :: integer() >= 0} |
4435                     {os_pid, OsPid :: integer() >= 0 | undefined}
4436                 Result = [ResultItem] | undefined
4437
4438              Returns a list containing tuples with information about Port, or
4439              undefined  if  the  port is not open. The order of the tuples is
4440              undefined, and all the tuples are not mandatory. If the port  is
4441              closed  and  the  calling  process  was previously linked to the
4442              port, the exit signal from the port is guaranteed to  be  deliv‐
4443              ered before port_info/1 returns undefined.
4444
4445              The result contains information about the following Items:
4446
4447                * registered_name (if the port has a registered name)
4448
4449                * id
4450
4451                * connected
4452
4453                * links
4454
4455                * name
4456
4457                * input
4458
4459                * output
4460
4461              For more information about the different Items, see port_info/2.
4462
4463              Failure:  badarg  if  Port is not a local port identifier, or an
4464              atom.
4465
4466       erlang:port_info(Port, Item :: connected) ->
4467                           {connected, Pid} | undefined
4468
4469              Types:
4470
4471                 Port = port() | atom()
4472                 Pid = pid()
4473
4474              Pid is the process identifier of the process  connected  to  the
4475              port.
4476
4477              If  the  port  identified  by  Port  is  not  open, undefined is
4478              returned. If the port is closed and the calling process was pre‐
4479              viously  linked  to  the  port, the exit signal from the port is
4480              guaranteed to be delivered before port_info/2 returns undefined.
4481
4482              Failure: badarg if Port is not a local port  identifier,  or  an
4483              atom.
4484
4485       erlang:port_info(Port, Item :: id) -> {id, Index} | undefined
4486
4487              Types:
4488
4489                 Port = port() | atom()
4490                 Index = integer() >= 0
4491
4492              Index  is the internal index of the port. This index can be used
4493              to separate ports.
4494
4495              If the port  identified  by  Port  is  not  open,  undefined  is
4496              returned. If the port is closed and the calling process was pre‐
4497              viously linked to the port, the exit signal  from  the  port  is
4498              guaranteed to be delivered before port_info/2 returns undefined.
4499
4500              Failure:  badarg  if  Port is not a local port identifier, or an
4501              atom.
4502
4503       erlang:port_info(Port, Item :: input) ->
4504                           {input, Bytes} | undefined
4505
4506              Types:
4507
4508                 Port = port() | atom()
4509                 Bytes = integer() >= 0
4510
4511              Bytes is the total number of bytes read from the port.
4512
4513              If the port  identified  by  Port  is  not  open,  undefined  is
4514              returned. If the port is closed and the calling process was pre‐
4515              viously linked to the port, the exit signal  from  the  port  is
4516              guaranteed to be delivered before port_info/2 returns undefined.
4517
4518              Failure:  badarg  if  Port is not a local port identifier, or an
4519              atom.
4520
4521       erlang:port_info(Port, Item :: links) -> {links, Pids} | undefined
4522
4523              Types:
4524
4525                 Port = port() | atom()
4526                 Pids = [pid()]
4527
4528              Pids is a list of the process identifiers of the processes  that
4529              the port is linked to.
4530
4531              If  the  port  identified  by  Port  is  not  open, undefined is
4532              returned. If the port is closed and the calling process was pre‐
4533              viously  linked  to  the  port, the exit signal from the port is
4534              guaranteed to be delivered before port_info/2 returns undefined.
4535
4536              Failure: badarg if Port is not a local port  identifier,  or  an
4537              atom.
4538
4539       erlang:port_info(Port, Item :: locking) ->
4540                           {locking, Locking} | undefined
4541
4542              Types:
4543
4544                 Port = port() | atom()
4545                 Locking = false | port_level | driver_level
4546
4547              Locking is one of the following:
4548
4549                * port_level (port-specific locking)
4550
4551                * driver_level (driver-specific locking)
4552
4553              Notice that these results are highly implementation-specific and
4554              can change in a future release.
4555
4556              If the port  identified  by  Port  is  not  open,  undefined  is
4557              returned. If the port is closed and the calling process was pre‐
4558              viously linked to the port, the exit signal  from  the  port  is
4559              guaranteed to be delivered before port_info/2 returns undefined.
4560
4561              Failure:  badarg  if  Port is not a local port identifier, or an
4562              atom.
4563
4564       erlang:port_info(Port, Item :: memory) ->
4565                           {memory, Bytes} | undefined
4566
4567              Types:
4568
4569                 Port = port() | atom()
4570                 Bytes = integer() >= 0
4571
4572              Bytes is the total number of bytes allocated for  this  port  by
4573              the  runtime  system.  The port itself can have allocated memory
4574              that is not included in Bytes.
4575
4576              If the port  identified  by  Port  is  not  open,  undefined  is
4577              returned. If the port is closed and the calling process was pre‐
4578              viously linked to the port, the exit signal  from  the  port  is
4579              guaranteed to be delivered before port_info/2 returns undefined.
4580
4581              Failure:  badarg  if  Port is not a local port identifier, or an
4582              atom.
4583
4584       erlang:port_info(Port, Item :: monitors) ->
4585                           {monitors, Monitors} | undefined
4586
4587              Types:
4588
4589                 Port = port() | atom()
4590                 Monitors = [{process, pid()}]
4591
4592              Monitors represent processes monitored by this port.
4593
4594              If the port  identified  by  Port  is  not  open,  undefined  is
4595              returned. If the port is closed and the calling process was pre‐
4596              viously linked to the port, the exit signal  from  the  port  is
4597              guaranteed to be delivered before port_info/2 returns undefined.
4598
4599              Failure:  badarg  if  Port is not a local port identifier, or an
4600              atom.
4601
4602       erlang:port_info(Port, Item :: monitored_by) ->
4603                           {monitored_by, MonitoredBy} | undefined
4604
4605              Types:
4606
4607                 Port = port() | atom()
4608                 MonitoredBy = [pid()]
4609
4610              Returns list of pids that  are  monitoring  given  port  at  the
4611              moment.
4612
4613              If  the  port  identified  by  Port  is  not  open, undefined is
4614              returned. If the port is closed and the calling process was pre‐
4615              viously  linked  to  the  port, the exit signal from the port is
4616              guaranteed to be delivered before port_info/2 returns undefined.
4617
4618              Failure: badarg if Port is not a local port  identifier,  or  an
4619              atom.
4620
4621       erlang:port_info(Port, Item :: name) -> {name, Name} | undefined
4622
4623              Types:
4624
4625                 Port = port() | atom()
4626                 Name = string()
4627
4628              Name is the command name set by open_port/2.
4629
4630              If  the  port  identified  by  Port  is  not  open, undefined is
4631              returned. If the port is closed and the calling process was pre‐
4632              viously  linked  to  the  port, the exit signal from the port is
4633              guaranteed to be delivered before port_info/2 returns undefined.
4634
4635              Failure: badarg if Port is not a local port  identifier,  or  an
4636              atom.
4637
4638       erlang:port_info(Port, Item :: os_pid) ->
4639                           {os_pid, OsPid} | undefined
4640
4641              Types:
4642
4643                 Port = port() | atom()
4644                 OsPid = integer() >= 0 | undefined
4645
4646              OsPid is the process identifier (or equivalent) of an OS process
4647              created  with  open_port({spawn  |  spawn_executable,  Command},
4648              Options).  If  the  port  is  not  the  result of spawning an OS
4649              process, the value is undefined.
4650
4651              If the port  identified  by  Port  is  not  open,  undefined  is
4652              returned. If the port is closed and the calling process was pre‐
4653              viously linked to the port, the exit signal  from  the  port  is
4654              guaranteed to be delivered before port_info/2 returns undefined.
4655
4656              Failure:  badarg  if  Port is not a local port identifier, or an
4657              atom.
4658
4659       erlang:port_info(Port, Item :: output) ->
4660                           {output, Bytes} | undefined
4661
4662              Types:
4663
4664                 Port = port() | atom()
4665                 Bytes = integer() >= 0
4666
4667              Bytes is the total number of bytes  written  to  the  port  from
4668              Erlang processes using port_command/2, port_command/3, or Port !
4669              {Owner, {command, Data}.
4670
4671              If the port  identified  by  Port  is  not  open,  undefined  is
4672              returned. If the port is closed and the calling process was pre‐
4673              viously linked to the port, the exit signal  from  the  port  is
4674              guaranteed to be delivered before port_info/2 returns undefined.
4675
4676              Failure:  badarg  if  Port is not a local port identifier, or an
4677              atom.
4678
4679       erlang:port_info(Port, Item :: parallelism) ->
4680                           {parallelism, Boolean} | undefined
4681
4682              Types:
4683
4684                 Port = port() | atom()
4685                 Boolean = boolean()
4686
4687              Boolean corresponds to the port parallelism hint  used  by  this
4688              port.   For   more   information,   see  option  parallelism  of
4689              open_port/2.
4690
4691       erlang:port_info(Port, Item :: queue_size) ->
4692                           {queue_size, Bytes} | undefined
4693
4694              Types:
4695
4696                 Port = port() | atom()
4697                 Bytes = integer() >= 0
4698
4699              Bytes is the total number of bytes queued by the port using  the
4700              ERTS driver queue implementation.
4701
4702              If  the  port  identified  by  Port  is  not  open, undefined is
4703              returned. If the port is closed and the calling process was pre‐
4704              viously  linked  to  the  port, the exit signal from the port is
4705              guaranteed to be delivered before port_info/2 returns undefined.
4706
4707              Failure: badarg if Port is not a local port  identifier,  or  an
4708              atom.
4709
4710       erlang:port_info(Port, Item :: registered_name) ->
4711                           {registered_name, RegisteredName} |
4712                           [] | undefined
4713
4714              Types:
4715
4716                 Port = port() | atom()
4717                 RegisteredName = atom()
4718
4719              RegisteredName  is  the registered name of the port. If the port
4720              has no registered name, [] is returned.
4721
4722              If the port  identified  by  Port  is  not  open,  undefined  is
4723              returned. If the port is closed and the calling process was pre‐
4724              viously linked to the port, the exit signal  from  the  port  is
4725              guaranteed to be delivered before port_info/2 returns undefined.
4726
4727              Failure:  badarg  if  Port is not a local port identifier, or an
4728              atom.
4729
4730       port_to_list(Port) -> string()
4731
4732              Types:
4733
4734                 Port = port()
4735
4736              Returns a string corresponding to the text representation of the
4737              port identifier Port.
4738
4739       erlang:ports() -> [port()]
4740
4741              Returns  a  list  of  port  identifiers corresponding to all the
4742              ports existing on the local node.
4743
4744              Notice that an exiting port exists, but is not open.
4745
4746       pre_loaded() -> [module()]
4747
4748              Returns a list of Erlang modules that are preloaded in the  sys‐
4749              tem. As all loading of code is done through the file system, the
4750              file system must have been loaded previously.  Hence,  at  least
4751              the module init must be preloaded.
4752
4753       erlang:process_display(Pid, Type) -> true
4754
4755              Types:
4756
4757                 Pid = pid()
4758                 Type = backtrace
4759
4760              Writes  information  about  the  local  process  Pid on standard
4761              error. The only allowed value for the atom  Type  is  backtrace,
4762              which  shows  the contents of the call stack, including informa‐
4763              tion about the call chain, with  the  current  function  printed
4764              first. The format of the output is not further defined.
4765
4766       process_flag(Flag :: trap_exit, Boolean) -> OldBoolean
4767
4768              Types:
4769
4770                 Boolean = OldBoolean = boolean()
4771
4772              When  trap_exit  is  set  to  true,  exit  signals arriving to a
4773              process are converted to {'EXIT', From, Reason} messages,  which
4774              can  be  received  as  ordinary messages. If trap_exit is set to
4775              false, the process exits if it receives  an  exit  signal  other
4776              than normal and the exit signal is propagated to its linked pro‐
4777              cesses. Application processes are normally not to trap exits.
4778
4779              Returns the old value of the flag.
4780
4781              See also exit/2.
4782
4783       process_flag(Flag :: error_handler, Module) -> OldModule
4784
4785              Types:
4786
4787                 Module = OldModule = atom()
4788
4789              Used by a process to redefine the error  handler  for  undefined
4790              function calls and undefined registered processes. Inexperienced
4791              users are not to use this flag, as code auto-loading depends  on
4792              the correct operation of the error handling module.
4793
4794              Returns the old value of the flag.
4795
4796       process_flag(Flag :: min_heap_size, MinHeapSize) -> OldMinHeapSize
4797
4798              Types:
4799
4800                 MinHeapSize = OldMinHeapSize = integer() >= 0
4801
4802              Changes the minimum heap size for the calling process.
4803
4804              Returns the old value of the flag.
4805
4806       process_flag(Flag :: min_bin_vheap_size, MinBinVHeapSize) ->
4807                       OldMinBinVHeapSize
4808
4809              Types:
4810
4811                 MinBinVHeapSize = OldMinBinVHeapSize = integer() >= 0
4812
4813              Changes  the  minimum  binary  virtual heap size for the calling
4814              process.
4815
4816              Returns the old value of the flag.
4817
4818       process_flag(Flag :: max_heap_size, MaxHeapSize) -> OldMaxHeapSize
4819
4820              Types:
4821
4822                 MaxHeapSize = OldMaxHeapSize = max_heap_size()
4823                 max_heap_size() =
4824                     integer() >= 0 |
4825                     #{size => integer() >= 0,
4826                       kill => boolean(),
4827                       error_logger => boolean()}
4828
4829              This flag sets the maximum heap size for the calling process. If
4830              MaxHeapSize  is  an  integer, the system default values for kill
4831              and error_logger are used.
4832
4833                size:
4834                  The maximum size in words of the process. If  set  to  zero,
4835                  the  heap size limit is disabled. badarg is be thrown if the
4836                  value is smaller than min_heap_size. The size check is  only
4837                  done when a garbage collection is triggered.
4838
4839                  size  is the entire heap of the process when garbage collec‐
4840                  tion is triggered. This includes all generational heaps, the
4841                  process  stack, any  messages that are considered to be part
4842                  of the heap, and any extra memory that the garbage collector
4843                  needs during collection.
4844
4845                  size    is    the   same   as   can   be   retrieved   using
4846                  erlang:process_info(Pid,  total_heap_size),  or  by   adding
4847                  heap_block_size,   old_heap_block_size  and  mbuf_size  from
4848                  erlang:process_info(Pid, garbage_collection_info).
4849
4850                kill:
4851                  When set to true, the runtime system  sends  an  untrappable
4852                  exit  signal  with reason kill to the process if the maximum
4853                  heap size is reached. The garbage collection that  triggered
4854                  the kill is not completed, instead the process exits as soon
4855                  as possible. When set to false, no exit signal  is  sent  to
4856                  the process, instead it continues executing.
4857
4858                  If  kill  is not defined in the map, the system default will
4859                  be used. The default system  default  is  true.  It  can  be
4860                  changed  by  either  option +hmaxk in erl(1), or erlang:sys‐
4861                  tem_flag(max_heap_size, MaxHeapSize).
4862
4863                error_logger:
4864                  When set to true, the runtime system logs an error event via
4865                  logger,  containing details about the process when the maxi‐
4866                  mum heap size is reached. One log event is  sent  each  time
4867                  the limit is reached.
4868
4869                  If  error_logger  is  not  defined  in  the  map, the system
4870                  default is used. The default system default is true. It  can
4871                  be  changed  by  either  the  option  +hmaxel int erl(1), or
4872                  erlang:system_flag(max_heap_size, MaxHeapSize).
4873
4874              The heap size of a process is quite hard to predict,  especially
4875              the amount of memory that is used during the garbage collection.
4876              When contemplating using this option, it is recommended to first
4877              run  it in production with kill set to false and inspect the log
4878              events to see what the normal peak sizes of the processes in the
4879              system is and then tune the value accordingly.
4880
4881       process_flag(Flag :: message_queue_data, MQD) -> OldMQD
4882
4883              Types:
4884
4885                 MQD = OldMQD = message_queue_data()
4886                 message_queue_data() = off_heap | on_heap
4887
4888              Determines how messages in the message queue are stored, as fol‐
4889              lows:
4890
4891                off_heap:
4892                  All messages in the message queue will be stored outside the
4893                  process  heap.  This implies that no messages in the message
4894                  queue will be part of a garbage collection of the process.
4895
4896                on_heap:
4897                  All messages in the message queue will eventually be  placed
4898                  on  the  process  heap.  They  can,  however, be temporarily
4899                  stored off the heap. This is how messages have  always  been
4900                  stored up until ERTS 8.0.
4901
4902              The  default  value  of  the  message_queue_data process flag is
4903              determined by the command-line argument +hmqd in erl(1).
4904
4905              If the process may potentially accumulate a large number of mes‐
4906              sages  in  its  queue it is recommended to set the flag value to
4907              off_heap. This is due to the fact that the garbage collection of
4908              a process that has a large number of messages stored on the heap
4909              can become extremely expensive and the process can consume large
4910              amounts of memory. The performance of the actual message passing
4911              is, however, generally better when the flag value is on_heap.
4912
4913              Changing the flag value  causes  any  existing  messages  to  be
4914              moved. The move operation is initiated, but not necessarily com‐
4915              pleted, by the time the function returns.
4916
4917              Returns the old value of the flag.
4918
4919       process_flag(Flag :: priority, Level) -> OldLevel
4920
4921              Types:
4922
4923                 Level = OldLevel = priority_level()
4924                 priority_level() = low | normal | high | max
4925
4926              Sets the process priority. Level is an atom. Four priority  lev‐
4927              els exist: low, normal, high, and max. Default is normal.
4928
4929          Note:
4930              Priority  level  max  is reserved for internal use in the Erlang
4931              runtime system, and is not to be used by others.
4932
4933
4934              Internally in each priority level, processes are scheduled in  a
4935              round robin fashion.
4936
4937              Execution  of  processes  on  priority normal and low are inter‐
4938              leaved. Processes on priority low  are  selected  for  execution
4939              less frequently than processes on priority normal.
4940
4941              When  runnable processes on priority high exist, no processes on
4942              priority low or normal are selected for execution.  Notice  how‐
4943              ever  that  this does not mean that no processes on priority low
4944              or normal can run when processes are running on  priority  high.
4945              When using multiple schedulers, more processes can be running in
4946              parallel than processes on priority high. That is, a low  and  a
4947              high priority process can execute at the same time.
4948
4949              When  runnable  processes on priority max exist, no processes on
4950              priority low, normal, or high are  selected  for  execution.  As
4951              with priority high, processes on lower priorities can execute in
4952              parallel with processes on priority max.
4953
4954              Scheduling is pre-emptive. Regardless of priority, a process  is
4955              pre-empted  when  it  has consumed more than a certain number of
4956              reductions since the last time it was selected for execution.
4957
4958          Note:
4959              Do not depend on the scheduling  to  remain  exactly  as  it  is
4960              today. Scheduling is likely to be changed in a future release to
4961              use available processor cores better.
4962
4963
4964              There is no automatic mechanism for avoiding priority inversion,
4965              such  as  priority  inheritance or priority ceilings. When using
4966              priorities, take this into account and handle such scenarios  by
4967              yourself.
4968
4969              Making calls from a high priority process into code that you has
4970              no control over can cause the high priority process to wait  for
4971              a  process  with lower priority. That is, effectively decreasing
4972              the priority of the high priority process during the call.  Even
4973              if  this  is  not the case with one version of the code that you
4974              have no control over, it can be the case in a future version  of
4975              it.  This  can,  for  example,  occur if a high priority process
4976              triggers code loading, as the code server runs on priority  nor‐
4977              mal.
4978
4979              Other priorities than normal are normally not needed. When other
4980              priorities are used, use them  with  care,  especially  priority
4981              high.  A  process  on  priority high is only to perform work for
4982              short periods. Busy looping for long periods in a high  priority
4983              process  causes  most  likely problems, as important OTP servers
4984              run on priority normal.
4985
4986              Returns the old value of the flag.
4987
4988       process_flag(Flag :: save_calls, N) -> OldN
4989
4990              Types:
4991
4992                 N = OldN = 0..10000
4993
4994              N must be an integer in the interval 0..10000. If N  >  0,  call
4995              saving  is made active for the process. This means that informa‐
4996              tion about the N most recent global function calls,  BIF  calls,
4997              sends,  and  receives  made  by the process are saved in a list,
4998              which can be retrieved  with  process_info(Pid,  last_calls).  A
4999              global  function call is one in which the module of the function
5000              is explicitly mentioned. Only a fixed amount of  information  is
5001              saved, as follows:
5002
5003                * A tuple {Module, Function, Arity} for function calls
5004
5005                * The  atoms  send,  'receive',  and  timeout  for  sends  and
5006                  receives ('receive' when a message is received  and  timeout
5007                  when a receive times out)
5008
5009              If  N = 0, call saving is disabled for the process, which is the
5010              default. Whenever the size of the call saving list is  set,  its
5011              contents are reset.
5012
5013              Returns the old value of the flag.
5014
5015       process_flag(Flag :: sensitive, Boolean) -> OldBoolean
5016
5017              Types:
5018
5019                 Boolean = OldBoolean = boolean()
5020
5021              Sets  or  clears  flag sensitive for the current process. When a
5022              process   has   been   marked   as    sensitive    by    calling
5023              process_flag(sensitive,  true),  features  in the runtime system
5024              that can be used for examining the data or inner working of  the
5025              process are silently disabled.
5026
5027              Features  that are disabled include (but are not limited to) the
5028              following:
5029
5030                * Tracing. Trace flags can still be set for the  process,  but
5031                  no trace messages of any kind are generated. (If flag sensi‐
5032                  tive is turned off, trace messages are  again  generated  if
5033                  any trace flags are set.)
5034
5035                * Sequential tracing. The sequential trace token is propagated
5036                  as usual, but no sequential trace messages are generated.
5037
5038              process_info/1,2 cannot be used to read out the message queue or
5039              the process dictionary (both are returned as empty lists).
5040
5041              Stack back-traces cannot be displayed for the process.
5042
5043              In  crash dumps, the stack, messages, and the process dictionary
5044              are omitted.
5045
5046              If {save_calls,N} has been set  for  the  process,  no  function
5047              calls  are  saved to the call saving list. (The call saving list
5048              is not cleared. Also, send, receive,  and  time-out  events  are
5049              still added to the list.)
5050
5051              Returns the old value of the flag.
5052
5053       process_flag(Pid, Flag, Value) -> OldValue
5054
5055              Types:
5056
5057                 Pid = pid()
5058                 Flag = save_calls
5059                 Value = OldValue = integer() >= 0
5060
5061              Sets  certain  flags  for the process Pid, in the same manner as
5062              process_flag/2. Returns the old value of  the  flag.  The  valid
5063              values   for  Flag  are  only  a  subset  of  those  allowed  in
5064              process_flag/2, namely save_calls.
5065
5066              Failure: badarg if Pid is not a local process.
5067
5068       process_info(Pid) -> Info
5069
5070              Types:
5071
5072                 Pid = pid()
5073                 Info = [InfoTuple] | undefined
5074                 InfoTuple = process_info_result_item()
5075                 process_info_result_item() =
5076                     {backtrace, Bin :: binary()} |
5077                     {binary,
5078                      BinInfo ::
5079                          [{integer() >= 0,
5080                            integer() >= 0,
5081                            integer() >= 0}]} |
5082                     {catchlevel, CatchLevel :: integer() >= 0} |
5083                     {current_function,
5084                      {Module :: module(), Function :: atom(), Arity :: arity()} |
5085                      undefined} |
5086                     {current_location,
5087                      {Module :: module(),
5088                       Function :: atom(),
5089                       Arity :: arity(),
5090                       Location ::
5091                           [{file, Filename :: string()} |
5092                            {line, Line :: integer() >= 1}]}} |
5093                     {current_stacktrace, Stack :: [stack_item()]} |
5094                     {dictionary, Dictionary :: [{Key :: term(), Value :: term()}]} |
5095                     {error_handler, Module :: module()} |
5096                     {garbage_collection, GCInfo :: [{atom(), integer() >= 0}]} |
5097                     {garbage_collection_info,
5098                      GCInfo :: [{atom(), integer() >= 0}]} |
5099                     {group_leader, GroupLeader :: pid()} |
5100                     {heap_size, Size :: integer() >= 0} |
5101                     {initial_call, mfa()} |
5102                     {links, PidsAndPorts :: [pid() | port()]} |
5103                     {last_calls, false | (Calls :: [mfa()])} |
5104                     {memory, Size :: integer() >= 0} |
5105                     {message_queue_len, MessageQueueLen :: integer() >= 0} |
5106                     {messages, MessageQueue :: [term()]} |
5107                     {min_heap_size, MinHeapSize :: integer() >= 0} |
5108                     {min_bin_vheap_size, MinBinVHeapSize :: integer() >= 0} |
5109                     {max_heap_size, MaxHeapSize :: max_heap_size()} |
5110                     {monitored_by,
5111                      MonitoredBy :: [pid() | port() | nif_resource()]} |
5112                     {monitors,
5113                      Monitors ::
5114                          [{process | port,
5115                            Pid ::
5116                                pid() |
5117                                port() |
5118                                {RegName :: atom(), Node :: node()}}]} |
5119                     {message_queue_data, MQD :: message_queue_data()} |
5120                     {priority, Level :: priority_level()} |
5121                     {reductions, Number :: integer() >= 0} |
5122                     {registered_name, [] | (Atom :: atom())} |
5123                     {sequential_trace_token,
5124                      [] | (SequentialTraceToken :: term())} |
5125                     {stack_size, Size :: integer() >= 0} |
5126                     {status,
5127                      Status ::
5128                          exiting | garbage_collecting | waiting | running |
5129                          runnable | suspended} |
5130                     {suspending,
5131                      SuspendeeList ::
5132                          [{Suspendee :: pid(),
5133                            ActiveSuspendCount :: integer() >= 0,
5134                            OutstandingSuspendCount :: integer() >= 0}]} |
5135                     {total_heap_size, Size :: integer() >= 0} |
5136                     {trace, InternalTraceFlags :: integer() >= 0} |
5137                     {trap_exit, Boolean :: boolean()}
5138                 priority_level() = low | normal | high | max
5139                 stack_item() =
5140                     {Module :: module(),
5141                      Function :: atom(),
5142                      Arity :: arity() | (Args :: [term()]),
5143                      Location ::
5144                          [{file, Filename :: string()} |
5145                           {line, Line :: integer() >= 1}]}
5146                 max_heap_size() =
5147                     integer() >= 0 |
5148                     #{size => integer() >= 0,
5149                       kill => boolean(),
5150                       error_logger => boolean()}
5151                 message_queue_data() = off_heap | on_heap
5152
5153              Returns a list containing InfoTuples with miscellaneous informa‐
5154              tion  about  the  process identified by Pid, or undefined if the
5155              process is not alive.
5156
5157              The order of the InfoTuples is undefined and all InfoTuples  are
5158              not  mandatory. The InfoTuples part of the result can be changed
5159              without prior notice.
5160
5161              The InfoTuples with the following items are part of the result:
5162
5163                * current_function
5164
5165                * initial_call
5166
5167                * status
5168
5169                * message_queue_len
5170
5171                * links
5172
5173                * dictionary
5174
5175                * trap_exit
5176
5177                * error_handler
5178
5179                * priority
5180
5181                * group_leader
5182
5183                * total_heap_size
5184
5185                * heap_size
5186
5187                * stack_size
5188
5189                * reductions
5190
5191                * garbage_collection
5192
5193              If the process identified by Pid has a registered name, also  an
5194              InfoTuple with item registered_name is included.
5195
5196              For information about specific InfoTuples, see process_info/2.
5197
5198          Warning:
5199              This BIF is intended for debugging only. For all other purposes,
5200              use process_info/2.
5201
5202
5203              Failure: badarg if Pid is not a local process.
5204
5205       process_info(Pid, Item) -> InfoTuple | [] | undefined
5206
5207       process_info(Pid, ItemList) -> InfoTupleList | [] | undefined
5208
5209              Types:
5210
5211                 Pid = pid()
5212                 ItemList = [Item]
5213                 Item = process_info_item()
5214                 InfoTupleList = [InfoTuple]
5215                 InfoTuple = process_info_result_item()
5216                 process_info_item() =
5217                     backtrace | binary | catchlevel | current_function |
5218                     current_location | current_stacktrace | dictionary |
5219                     error_handler | garbage_collection | garbage_collection_info |
5220                     group_leader | heap_size | initial_call | links | last_calls |
5221                     memory | message_queue_len | messages | min_heap_size |
5222                     min_bin_vheap_size | monitored_by | monitors |
5223                     message_queue_data | priority | reductions | registered_name |
5224                     sequential_trace_token | stack_size | status | suspending |
5225                     total_heap_size | trace | trap_exit
5226                 process_info_result_item() =
5227                     {backtrace, Bin :: binary()} |
5228                     {binary,
5229                      BinInfo ::
5230                          [{integer() >= 0,
5231                            integer() >= 0,
5232                            integer() >= 0}]} |
5233                     {catchlevel, CatchLevel :: integer() >= 0} |
5234                     {current_function,
5235                      {Module :: module(), Function :: atom(), Arity :: arity()} |
5236                      undefined} |
5237                     {current_location,
5238                      {Module :: module(),
5239                       Function :: atom(),
5240                       Arity :: arity(),
5241                       Location ::
5242                           [{file, Filename :: string()} |
5243                            {line, Line :: integer() >= 1}]}} |
5244                     {current_stacktrace, Stack :: [stack_item()]} |
5245                     {dictionary, Dictionary :: [{Key :: term(), Value :: term()}]} |
5246                     {error_handler, Module :: module()} |
5247                     {garbage_collection, GCInfo :: [{atom(), integer() >= 0}]} |
5248                     {garbage_collection_info,
5249                      GCInfo :: [{atom(), integer() >= 0}]} |
5250                     {group_leader, GroupLeader :: pid()} |
5251                     {heap_size, Size :: integer() >= 0} |
5252                     {initial_call, mfa()} |
5253                     {links, PidsAndPorts :: [pid() | port()]} |
5254                     {last_calls, false | (Calls :: [mfa()])} |
5255                     {memory, Size :: integer() >= 0} |
5256                     {message_queue_len, MessageQueueLen :: integer() >= 0} |
5257                     {messages, MessageQueue :: [term()]} |
5258                     {min_heap_size, MinHeapSize :: integer() >= 0} |
5259                     {min_bin_vheap_size, MinBinVHeapSize :: integer() >= 0} |
5260                     {max_heap_size, MaxHeapSize :: max_heap_size()} |
5261                     {monitored_by,
5262                      MonitoredBy :: [pid() | port() | nif_resource()]} |
5263                     {monitors,
5264                      Monitors ::
5265                          [{process | port,
5266                            Pid ::
5267                                pid() |
5268                                port() |
5269                                {RegName :: atom(), Node :: node()}}]} |
5270                     {message_queue_data, MQD :: message_queue_data()} |
5271                     {priority, Level :: priority_level()} |
5272                     {reductions, Number :: integer() >= 0} |
5273                     {registered_name, [] | (Atom :: atom())} |
5274                     {sequential_trace_token,
5275                      [] | (SequentialTraceToken :: term())} |
5276                     {stack_size, Size :: integer() >= 0} |
5277                     {status,
5278                      Status ::
5279                          exiting | garbage_collecting | waiting | running |
5280                          runnable | suspended} |
5281                     {suspending,
5282                      SuspendeeList ::
5283                          [{Suspendee :: pid(),
5284                            ActiveSuspendCount :: integer() >= 0,
5285                            OutstandingSuspendCount :: integer() >= 0}]} |
5286                     {total_heap_size, Size :: integer() >= 0} |
5287                     {trace, InternalTraceFlags :: integer() >= 0} |
5288                     {trap_exit, Boolean :: boolean()}
5289                 stack_item() =
5290                     {Module :: module(),
5291                      Function :: atom(),
5292                      Arity :: arity() | (Args :: [term()]),
5293                      Location ::
5294                          [{file, Filename :: string()} |
5295                           {line, Line :: integer() >= 1}]}
5296                 priority_level() = low | normal | high | max
5297                 max_heap_size() =
5298                     integer() >= 0 |
5299                     #{size => integer() >= 0,
5300                       kill => boolean(),
5301                       error_logger => boolean()}
5302                 message_queue_data() = off_heap | on_heap
5303
5304              Returns information about the  process  identified  by  Pid,  as
5305              specified  by Item or ItemList. Returns undefined if the process
5306              is not alive.
5307
5308              If the process is alive and a  single  Item  is  specified,  the
5309              returned  value  is the corresponding InfoTuple, unless Item =:=
5310              registered_name and the process has no registered name. In  this
5311              case,  []  is returned. This strange behavior is because of his‐
5312              torical reasons, and is kept for backward compatibility.
5313
5314              If ItemList is specified, the result is InfoTupleList. The Info‐
5315              Tuples  in  InfoTupleList  are  included  with the corresponding
5316              Items in the same order as the Items were included in  ItemList.
5317              Valid Items can be included multiple times in ItemList.
5318
5319          Note:
5320              If  registered_name  is  part of ItemList and the process has no
5321              name registered, a  {registered_name,  []},  InfoTuple  will  be
5322              included  in  the resulting InfoTupleList. This behavior is dif‐
5323              ferent when a single Item =:= registered_name is specified,  and
5324              when process_info/1 is used.
5325
5326
5327              Valid InfoTuples with corresponding Items:
5328
5329                {backtrace, Bin}:
5330                  Binary  Bin contains the same information as the output from
5331                  erlang:process_display(Pid, backtrace). Use binary_to_list/1
5332                  to obtain the string of characters from the binary.
5333
5334                {binary, BinInfo}:
5335                  BinInfo is a list containing miscellaneous information about
5336                  binaries on the heap of this process. This InfoTuple can  be
5337                  changed  or  removed  without  prior  notice. In the current
5338                  implementation BinInfo is a list of tuples. The tuples  con‐
5339                  tain; BinaryId, BinarySize, BinaryRefcCount.
5340
5341                  Depending  on  the  value  of the message_queue_data process
5342                  flag the message queue may be stored on the heap.
5343
5344                {catchlevel, CatchLevel}:
5345                  CatchLevel is the number of currently active catches in this
5346                  process.  This  InfoTuple  can be changed or removed without
5347                  prior notice.
5348
5349                {current_function, {Module, Function, Arity} | undefined}:
5350                  Module, Function, Arity is the current function call of  the
5351                  process.  The value undefined can be returned if the process
5352                  is currently executing native compiled code.
5353
5354                {current_location, {Module, Function, Arity, Location}}:
5355                  Module, Function, Arity is the current function call of  the
5356                  process.  Location  is  a  list of two-tuples describing the
5357                  location in the source code.
5358
5359                {current_stacktrace, Stack}:
5360                  Returns the current call stack  back-trace  (stacktrace)  of
5361                  the  process.  The stack has the same format as in the catch
5362                  part of a try. See The call-stack back  trace  (stacktrace).
5363                  The  depth  of  the stacktrace is truncated according to the
5364                  backtrace_depth system flag setting.
5365
5366                {dictionary, Dictionary}:
5367                  Dictionary is the process dictionary.
5368
5369                {error_handler, Module}:
5370                  Module is the error handler module used by the process  (for
5371                  undefined function calls, for example).
5372
5373                {garbage_collection, GCInfo}:
5374                  GCInfo  is a list containing miscellaneous information about
5375                  garbage collection for this process. The content  of  GCInfo
5376                  can be changed without prior notice.
5377
5378                {garbage_collection_info, GCInfo}:
5379                  GCInfo  is a list containing miscellaneous detailed informa‐
5380                  tion about garbage collection for this process. The  content
5381                  of  GCInfo  can be changed without prior notice. For details
5382                  about the  meaning  of  each  item,  see  gc_minor_start  in
5383                  erlang:trace/3.
5384
5385                {group_leader, GroupLeader}:
5386                  GroupLeader is the group leader for the I/O of the process.
5387
5388                {heap_size, Size}:
5389                  Size is the size in words of the youngest heap generation of
5390                  the process. This generation  includes  the  process  stack.
5391                  This information is highly implementation-dependent, and can
5392                  change if the implementation changes.
5393
5394                {initial_call, {Module, Function, Arity}}:
5395                  Module, Function, Arity is the initial  function  call  with
5396                  which the process was spawned.
5397
5398                {links, PidsAndPorts}:
5399                  PidsAndPorts is a list of process identifiers and port iden‐
5400                  tifiers, with processes or ports to which the process has  a
5401                  link.
5402
5403                {last_calls, false|Calls}:
5404                  The  value  is  false  if  call saving is not active for the
5405                  process (see process_flag/3). If call saving  is  active,  a
5406                  list  is  returned,  in  which  the last element is the most
5407                  recent called.
5408
5409                {memory, Size}:
5410
5411
5412                  Size is the size in bytes of the process. This includes call
5413                  stack, heap, and internal structures.
5414
5415                {message_queue_len, MessageQueueLen}:
5416                  MessageQueueLen  is  the number of messages currently in the
5417                  message queue of the process. This is the length of the list
5418                  MessageQueue  returned as the information item messages (see
5419                  below).
5420
5421                {messages, MessageQueue}:
5422                  MessageQueue is a list of the messages to the process, which
5423                  have not yet been processed.
5424
5425                {min_heap_size, MinHeapSize}:
5426                  MinHeapSize is the minimum heap size for the process.
5427
5428                {min_bin_vheap_size, MinBinVHeapSize}:
5429                  MinBinVHeapSize  is the minimum binary virtual heap size for
5430                  the process.
5431
5432                {monitored_by, MonitoredBy}:
5433                  A list of identifiers for all the processes, ports  and  NIF
5434                  resources, that are monitoring the process.
5435
5436                {monitors, Monitors}:
5437                  A  list  of  monitors (started by monitor/2) that are active
5438                  for the process. For a local process  monitor  or  a  remote
5439                  process  monitor  by a process identifier, the list consists
5440                  of:
5441
5442                  {process, Pid}:
5443                    Process is monitored by pid.
5444
5445                  {process, {RegName, Node}}:
5446                    Local or remote process is monitored by name.
5447
5448                  {port, PortId}:
5449                    Local port is monitored by port id.
5450
5451                  {port, {RegName, Node}}:
5452                    Local port is monitored by name. Please note, that  remote
5453                    port  monitors  are  not supported, so Node will always be
5454                    the local node name.
5455
5456                {message_queue_data, MQD}:
5457                  MQD is the current value of the  message_queue_data  process
5458                  flag,  which  can  be  either  off_heap or on_heap. For more
5459                  information,  see  the  documentation  of  process_flag(mes‐
5460                  sage_queue_data, MQD).
5461
5462                {priority, Level}:
5463                  Level  is  the  current  priority level for the process. For
5464                  more information on priorities,  see  process_flag(priority,
5465                  Level).
5466
5467                {reductions, Number}:
5468                  Number is the number of reductions executed by the process.
5469
5470                {registered_name, Atom}:
5471                  Atom  is  the registered process name. If the process has no
5472                  registered name, this tuple is not present in the list.
5473
5474                {sequential_trace_token, [] | SequentialTraceToken}:
5475                  SequentialTraceToken is the sequential trace token  for  the
5476                  process.  This  InfoTuple  can be changed or removed without
5477                  prior notice.
5478
5479                {stack_size, Size}:
5480                  Size is the stack size, in words, of the process.
5481
5482                {status, Status}:
5483                  Status is the status of the process and is one of  the  fol‐
5484                  lowing:
5485
5486                  * exiting
5487
5488                  * garbage_collecting
5489
5490                  * waiting (for a message)
5491
5492                  * running
5493
5494                  * runnable (ready to run, but another process is running)
5495
5496                  * suspended  (suspended  on  a  "busy"  port  or  by the BIF
5497                    erlang:suspend_process/1,2)
5498
5499                {suspending, SuspendeeList}:
5500                  SuspendeeList is a list of  {Suspendee,  ActiveSuspendCount,
5501                  OutstandingSuspendCount}  tuples.  Suspendee  is the process
5502                  identifier of a process that has been, or  is  to  be,  sus‐
5503                  pended  by  the  process  identified  by Pid through the BIF
5504                  erlang:suspend_process/2 or erlang:suspend_process/1.
5505
5506                  ActiveSuspendCount is the number of times Suspendee has been
5507                  suspended  by  Pid. OutstandingSuspendCount is the number of
5508                  not yet completed suspend requests sent by Pid, that is:
5509
5510                  * If ActiveSuspendCount =/= 0, Suspendee is currently in the
5511                    suspended state.
5512
5513                  * If  OutstandingSuspendCount  =/= 0, option asynchronous of
5514                    erlang:suspend_process/2 has been used and  the  suspendee
5515                    has not yet been suspended by Pid.
5516
5517                  Notice  that  ActiveSuspendCount and OutstandingSuspendCount
5518                  are not the total suspend count on Suspendee, only the parts
5519                  contributed by Pid.
5520
5521                {total_heap_size, Size}:
5522                  Size  is  the total size, in words, of all heap fragments of
5523                  the process. This includes the process stack and  any  unre‐
5524                  ceived messages that are considered to be part of the heap.
5525
5526                {trace, InternalTraceFlags}:
5527                  InternalTraceFlags  is  an integer representing the internal
5528                  trace flag for this process. This InfoTuple can  be  changed
5529                  or removed without prior notice.
5530
5531                {trap_exit, Boolean}:
5532                  Boolean  is true if the process is trapping exits, otherwise
5533                  false.
5534
5535              Notice that not all implementations support all these Items.
5536
5537              Failures:
5538
5539                badarg:
5540                  If Pid is not a local process.
5541
5542                badarg:
5543                  If Item is an invalid item.
5544
5545       processes() -> [pid()]
5546
5547              Returns a list of process identifiers corresponding to  all  the
5548              processes currently existing on the local node.
5549
5550              Notice  that  an  exiting process exists, but is not alive. That
5551              is, is_process_alive/1 returns false for an exiting process, but
5552              its  process identifier is part of the result returned from pro‐
5553              cesses/0.
5554
5555              Example:
5556
5557              > processes().
5558              [<0.0.0>,<0.2.0>,<0.4.0>,<0.5.0>,<0.7.0>,<0.8.0>]
5559
5560       purge_module(Module) -> true
5561
5562              Types:
5563
5564                 Module = atom()
5565
5566              Removes  old  code  for  Module.  Before  this  BIF   is   used,
5567              check_process_code/2  is to be called to check that no processes
5568              execute old code in the module.
5569
5570          Warning:
5571              This BIF is intended for the code server (see  code(3))  and  is
5572              not to be used elsewhere.
5573
5574
5575          Note:
5576              As  from  ERTS 8.0 (Erlang/OTP 19), any lingering processes that
5577              still execute the old code is killed by this function.  In  ear‐
5578              lier  versions,  such  incorrect use could cause much more fatal
5579              failures, like emulator crash.
5580
5581
5582              Failure: badarg if there is no old code for Module.
5583
5584       put(Key, Val) -> term()
5585
5586              Types:
5587
5588                 Key = Val = term()
5589
5590              Adds a new Key to the process dictionary,  associated  with  the
5591              value  Val,  and returns undefined. If Key exists, the old value
5592              is deleted and replaced by Val, and the function returns the old
5593              value. Example:
5594
5595              > X = put(name, walrus), Y = put(name, carpenter),
5596              Z = get(name),
5597              {X, Y, Z}.
5598              {undefined,walrus,carpenter}
5599
5600          Note:
5601              The  values  stored  when put is evaluated within the scope of a
5602              catch are not retracted if a throw is evaluated, or if an  error
5603              occurs.
5604
5605
5606       erlang:raise(Class, Reason, Stacktrace) -> no_return()
5607
5608              Types:
5609
5610                 Class = error | exit | throw
5611                 Reason = term()
5612                 Stacktrace = raise_stacktrace()
5613                 raise_stacktrace() =
5614                     [{module(), atom(), arity() | [term()]} |
5615                      {function(), [term()]}] |
5616                     [{module(), atom(), arity() | [term()], [{atom(), term()}]} |
5617                      {function(), [term()], [{atom(), term()}]}]
5618
5619              Stops  the execution of the calling process with an exception of
5620              the specified class, reason, and call  stack  backtrace  (stack‐
5621              trace).
5622
5623              Class  is  error,  exit,  or  throw.  So, if it were not for the
5624              stacktrace, erlang:raise(Class, Reason, Stacktrace)  is  equiva‐
5625              lent to erlang:Class(Reason).
5626
5627              Reason can be any term.
5628
5629              Stacktrace is a list as provided in a try-catch clause.
5630
5631              try
5632                  ...
5633              catch Class:Reason:Stacktrace ->
5634                  ...
5635              end
5636
5637              That  is, a list of four-tuples {Module, Function, Arity | Args,
5638              Location}, where Module and Function are atoms,  and  the  third
5639              element  is an integer arity or an argument list. The stacktrace
5640              can also contain {Fun, Args, Location} tuples, where  Fun  is  a
5641              local fun and Args is an argument list.
5642
5643              Element  Location at the end is optional. Omitting it is equiva‐
5644              lent to specifying an empty list.
5645
5646              The stacktrace is used as the exception stacktrace for the call‐
5647              ing  process;  it is truncated to the current maximum stacktrace
5648              depth.
5649
5650              As evaluating this function causes the process to terminate,  it
5651              has  no  return value unless the arguments are invalid, in which
5652              case the function returns the error reason badarg. If  you  want
5653              to be sure not to return, you can call error(erlang:raise(Class,
5654              Reason, Stacktrace)) and hope to distinguish exceptions later.
5655
5656       erlang:read_timer(TimerRef) -> Result
5657
5658              Types:
5659
5660                 TimerRef = reference()
5661                 Time = integer() >= 0
5662                 Result = Time | false
5663
5664              Reads  the   state   of   a   timer.   The   same   as   calling
5665              erlang:read_timer(TimerRef, []).
5666
5667       erlang:read_timer(TimerRef, Options) -> Result | ok
5668
5669              Types:
5670
5671                 TimerRef = reference()
5672                 Async = boolean()
5673                 Option = {async, Async}
5674                 Options = [Option]
5675                 Time = integer() >= 0
5676                 Result = Time | false
5677
5678              Reads  the  state  of  a  timer  that has been created by either
5679              erlang:start_timer or erlang:send_after. TimerRef identifies the
5680              timer, and was returned by the BIF that created the timer.
5681
5682              Options:
5683
5684                {async, Async}:
5685                  Asynchronous  request  for state information. Async defaults
5686                  to false, which causes the operation to  be  performed  syn‐
5687                  chronously.   In  this  case,  the  Result  is  returned  by
5688                  erlang:read_timer. When  Async  is  true,  erlang:read_timer
5689                  sends  an  asynchronous request for the state information to
5690                  the timer service that manages the timer, and  then  returns
5691                  ok.  A  message on the format {read_timer, TimerRef, Result}
5692                  is sent to the caller of erlang:read_timer when  the  opera‐
5693                  tion has been processed.
5694
5695              More Options can be added in the future.
5696
5697              If  Result is an integer, it represents the time in milliseconds
5698              left until the timer expires.
5699
5700              If Result is false, a timer corresponding to TimerRef could  not
5701              be  found. This because the timer had expired, or been canceled,
5702              or because TimerRef never has corresponded to a timer.  Even  if
5703              the  timer  has expired, it does not tell you whether or not the
5704              time-out message has arrived at its destination yet.
5705
5706          Note:
5707              The timer service that manages the timer can be co-located  with
5708              another scheduler than the scheduler that the calling process is
5709              executing on. If so, communication with the timer service  takes
5710              much  longer  time than if it is located locally. If the calling
5711              process is in a critical path, and can  do  other  things  while
5712              waiting for the result of this operation, you want to use option
5713              {async, true}. If  using  option  {async,  false},  the  calling
5714              process is blocked until the operation has been performed.
5715
5716
5717              See    also   erlang:send_after/4,   erlang:start_timer/4,   and
5718              erlang:cancel_timer/2.
5719
5720       ref_to_list(Ref) -> string()
5721
5722              Types:
5723
5724                 Ref = reference()
5725
5726              Returns a string corresponding to  the  text  representation  of
5727              Ref.
5728
5729          Warning:
5730              This  BIF  is  intended  for  debugging and is not to be used in
5731              application programs.
5732
5733
5734       register(RegName, PidOrPort) -> true
5735
5736              Types:
5737
5738                 RegName = atom()
5739                 PidOrPort = port() | pid()
5740
5741              Associates the name RegName with a process identifier (pid) or a
5742              port  identifier.  RegName,  which  must be an atom, can be used
5743              instead of the pid or port identifier in send operator  (RegName
5744              ! Message). Example:
5745
5746              > register(db, Pid).
5747              true
5748
5749              Failures:
5750
5751                badarg:
5752                  If PidOrPort is not an existing local process or port.
5753
5754                badarg:
5755                  If RegName is already in use.
5756
5757                badarg:
5758                  If  the process or port is already registered (already has a
5759                  name).
5760
5761                badarg:
5762                  If RegName is the atom undefined.
5763
5764       registered() -> [RegName]
5765
5766              Types:
5767
5768                 RegName = atom()
5769
5770              Returns a list of names that have been registered  using  regis‐
5771              ter/2, for example:
5772
5773              > registered().
5774              [code_server, file_server, init, user, my_db]
5775
5776       erlang:resume_process(Suspendee) -> true
5777
5778              Types:
5779
5780                 Suspendee = pid()
5781
5782              Decreases  the  suspend  count on the process identified by Sus‐
5783              pendee. Suspendee is previously to have been  suspended  through
5784              erlang:suspend_process/2   or  erlang:suspend_process/1  by  the
5785              process calling erlang:resume_process(Suspendee). When the  sus‐
5786              pend count on Suspendee reaches zero, Suspendee is resumed, that
5787              is, its state is changed from suspended into the  state  it  had
5788              before it was suspended.
5789
5790          Warning:
5791              This BIF is intended for debugging only.
5792
5793
5794              Failures:
5795
5796                badarg:
5797                   If Suspendee is not a process identifier.
5798
5799                badarg:
5800                   If the process calling erlang:resume_process/1 had not pre‐
5801                  viously increased the suspend count on the  process  identi‐
5802                  fied by Suspendee.
5803
5804                badarg:
5805                   If the process identified by Suspendee is not alive.
5806
5807       round(Number) -> integer()
5808
5809              Types:
5810
5811                 Number = number()
5812
5813              Returns an integer by rounding Number, for example:
5814
5815              round(5.5).
5816              6
5817
5818              Allowed in guard tests.
5819
5820       self() -> pid()
5821
5822              Returns the process identifier of the calling process, for exam‐
5823              ple:
5824
5825              > self().
5826              <0.26.0>
5827
5828              Allowed in guard tests.
5829
5830       erlang:send(Dest, Msg) -> Msg
5831
5832              Types:
5833
5834                 Dest = dst()
5835                 Msg = term()
5836                 dst() =
5837                     pid() |
5838                     port() |
5839                     (RegName :: atom()) |
5840                     {RegName :: atom(), Node :: node()}
5841
5842              Sends a message and returns Msg. This is the same as  using  the
5843              send operator: Dest ! Msg.
5844
5845              Dest  can  be  a  remote  or local process identifier, a (local)
5846              port, a locally registered name, or a tuple {RegName, Node}  for
5847              a registered name at another node.
5848
5849              The  function  fails  with a badarg run-time error if Dest is an
5850              atom name, but this name is not registered.  This  is  the  only
5851              case  when  send  fails  for an unreachable destination Dest (of
5852              correct type).
5853
5854       erlang:send(Dest, Msg, Options) -> Res
5855
5856              Types:
5857
5858                 Dest = dst()
5859                 Msg = term()
5860                 Options = [nosuspend | noconnect]
5861                 Res = ok | nosuspend | noconnect
5862                 dst() =
5863                     pid() |
5864                     port() |
5865                     (RegName :: atom()) |
5866                     {RegName :: atom(), Node :: node()}
5867
5868              Either sends a message and returns ok, or does not send the mes‐
5869              sage  but returns something else (see below). Otherwise the same
5870              as erlang:send/2. For more detailed  explanation  and  warnings,
5871              see erlang:send_nosuspend/2,3.
5872
5873              Options:
5874
5875                nosuspend:
5876                  If  the  sender  would  have to be suspended to do the send,
5877                  nosuspend is returned instead.
5878
5879                noconnect:
5880                   If the destination node would have to be auto-connected  to
5881                  do the send, noconnect is returned instead.
5882
5883          Warning:
5884              As with erlang:send_nosuspend/2,3: use with extreme care.
5885
5886
5887       erlang:send_after(Time, Dest, Msg) -> TimerRef
5888
5889              Types:
5890
5891                 Time = integer() >= 0
5892                 Dest = pid() | atom()
5893                 Msg = term()
5894                 TimerRef = reference()
5895
5896              Starts  a  timer.  The  same  as calling erlang:send_after(Time,
5897              Dest, Msg, []).
5898
5899       erlang:send_after(Time, Dest, Msg, Options) -> TimerRef
5900
5901              Types:
5902
5903                 Time = integer()
5904                 Dest = pid() | atom()
5905                 Msg = term()
5906                 Options = [Option]
5907                 Abs = boolean()
5908                 Option = {abs, Abs}
5909                 TimerRef = reference()
5910
5911              Starts a timer. When the timer expires, the message Msg is  sent
5912              to  the process identified by Dest. Apart from the format of the
5913              time-out   message,   this    function    works    exactly    as
5914              erlang:start_timer/4.
5915
5916       erlang:send_nosuspend(Dest, Msg) -> boolean()
5917
5918              Types:
5919
5920                 Dest = dst()
5921                 Msg = term()
5922                 dst() =
5923                     pid() |
5924                     port() |
5925                     (RegName :: atom()) |
5926                     {RegName :: atom(), Node :: node()}
5927
5928              The  same  as  erlang:send(Dest,  Msg, [nosuspend]), but returns
5929              true if the message was sent and false if the  message  was  not
5930              sent because the sender would have had to be suspended.
5931
5932              This  function  is intended for send operations to an unreliable
5933              remote node without ever blocking the sending (Erlang)  process.
5934              If  the connection to the remote node (usually not a real Erlang
5935              node, but a node written in C or Java) is overloaded, this func‐
5936              tion does not send the message and returns false.
5937
5938              The same occurs if Dest refers to a local port that is busy. For
5939              all other destinations (allowed for the ordinary  send  operator
5940              '!'), this function sends the message and returns true.
5941
5942              This  function  is only to be used in rare circumstances where a
5943              process communicates with Erlang nodes that can disappear  with‐
5944              out  any trace, causing the TCP buffers and the drivers queue to
5945              be over-full before the node is shut down (because of tick time-
5946              outs)  by  net_kernel.  The  normal  reaction  to take when this
5947              occurs is some kind of premature shutdown of the other node.
5948
5949              Notice that ignoring the return value from this  function  would
5950              result  in an unreliable message passing, which is contradictory
5951              to the Erlang programming model. The message is not sent if this
5952              function returns false.
5953
5954              In  many systems, transient states of overloaded queues are nor‐
5955              mal. Although this function returns false does not mean that the
5956              other  node  is  guaranteed  to be non-responsive, it could be a
5957              temporary overload. Also, a return value of true does only  mean
5958              that the message can be sent on the (TCP) channel without block‐
5959              ing; the message is not guaranteed to arrive at the remote node.
5960              For a disconnected non-responsive node, the return value is true
5961              (mimics the behavior of operator !). The expected  behavior  and
5962              the actions to take when the function returns false are applica‐
5963              tion- and hardware-specific.
5964
5965          Warning:
5966              Use with extreme care.
5967
5968
5969       erlang:send_nosuspend(Dest, Msg, Options) -> boolean()
5970
5971              Types:
5972
5973                 Dest = dst()
5974                 Msg = term()
5975                 Options = [noconnect]
5976                 dst() =
5977                     pid() |
5978                     port() |
5979                     (RegName :: atom()) |
5980                     {RegName :: atom(), Node :: node()}
5981
5982              The same as erlang:send(Dest, Msg, [nosuspend |  Options]),  but
5983              with a Boolean return value.
5984
5985              This  function behaves like erlang:send_nosuspend/2, but takes a
5986              third parameter, a list of options. The only  option  is  nocon‐
5987              nect,  which  makes the function return false if the remote node
5988              is not currently reachable by the local node. The normal  behav‐
5989              ior  is  to  try  to  connect  to  the node, which can stall the
5990              process during a short period. The use of option noconnect makes
5991              it possible to be sure not to get the slightest delay when send‐
5992              ing to a remote process. This is especially useful when communi‐
5993              cating  with  nodes that expect to always be the connecting part
5994              (that is, nodes written in C or Java).
5995
5996              Whenever the function returns false (either when a suspend would
5997              occur  or  when  noconnect  was  specified  and the node was not
5998              already connected), the message is guaranteed not to  have  been
5999              sent.
6000
6001          Warning:
6002              Use with extreme care.
6003
6004
6005       erlang:set_cookie(Node, Cookie) -> true
6006
6007              Types:
6008
6009                 Node = node()
6010                 Cookie = atom()
6011
6012              Sets the magic cookie of Node to the atom Cookie. If Node is the
6013              local node, the function also  sets  the  cookie  of  all  other
6014              unknown  nodes to Cookie (see section  Distributed Erlang in the
6015              Erlang Reference Manual in System Documentation).
6016
6017              Failure: function_clause if the local node is not alive.
6018
6019       setelement(Index, Tuple1, Value) -> Tuple2
6020
6021              Types:
6022
6023                 Index = integer() >= 1
6024                   1..tuple_size(Tuple1
6025                 Tuple1 = Tuple2 = tuple()
6026                 Value = term()
6027
6028              Returns a tuple that is a copy of argument Tuple1 with the  ele‐
6029              ment  specified  by integer argument Index (the first element is
6030              the element with index 1) replaced by argument Value, for  exam‐
6031              ple:
6032
6033              > setelement(2, {10, green, bottles}, red).
6034              {10,red,bottles}
6035
6036       size(Item) -> integer() >= 0
6037
6038              Types:
6039
6040                 Item = tuple() | binary()
6041
6042              Returns the number of elements in a tuple or the number of bytes
6043              in a binary or bitstring, for example:
6044
6045              > size({morni, mulle, bwange}).
6046              3
6047              > size(<<11, 22, 33>>).
6048              3
6049
6050              For bitstrings, the number of whole bytes is returned. That  is,
6051              if  the  number  of bits in the bitstring is not divisible by 8,
6052              the resulting number of bytes is rounded down.
6053
6054              Allowed in guard tests.
6055
6056              See also tuple_size/1, byte_size/1, and bit_size/1.
6057
6058       spawn(Fun) -> pid()
6059
6060              Types:
6061
6062                 Fun = function()
6063
6064              Returns the process identifier of a new process started  by  the
6065              application  of  Fun  to the empty list []. Otherwise works like
6066              spawn/3.
6067
6068       spawn(Node, Fun) -> pid()
6069
6070              Types:
6071
6072                 Node = node()
6073                 Fun = function()
6074
6075              Returns the process identifier of a new process started  by  the
6076              application  of  Fun  to the empty list [] on Node. If Node does
6077              not exist, a useless  pid  is  returned.  Otherwise  works  like
6078              spawn/3.
6079
6080       spawn(Module, Function, Args) -> pid()
6081
6082              Types:
6083
6084                 Module = module()
6085                 Function = atom()
6086                 Args = [term()]
6087
6088              Returns  the  process identifier of a new process started by the
6089              application of Module:Function to Args.
6090
6091              error_handler:undefined_function(Module,  Function,   Args)   is
6092              evaluated  by  the new process if Module:Function/Arity does not
6093              exist (where Arity is the length of Args). The error handler can
6094              be  redefined  (see  process_flag/2).  If error_handler is unde‐
6095              fined, or the user has redefined the default  error_handler  and
6096              its  replacement  is  undefined,  a  failure  with  reason undef
6097              occurs.
6098
6099              Example:
6100
6101              > spawn(speed, regulator, [high_speed, thin_cut]).
6102              <0.13.1>
6103
6104       spawn(Node, Module, Function, Args) -> pid()
6105
6106              Types:
6107
6108                 Node = node()
6109                 Module = module()
6110                 Function = atom()
6111                 Args = [term()]
6112
6113              Returns the process identifier (pid) of a new process started by
6114              the application of Module:Function to Args on Node. If Node does
6115              not exist, a useless  pid  is  returned.  Otherwise  works  like
6116              spawn/3.
6117
6118       spawn_link(Fun) -> pid()
6119
6120              Types:
6121
6122                 Fun = function()
6123
6124              Returns  the  process identifier of a new process started by the
6125              application of Fun to the empty  list  [].  A  link  is  created
6126              between  the  calling  process  and the new process, atomically.
6127              Otherwise works like spawn/3.
6128
6129       spawn_link(Node, Fun) -> pid()
6130
6131              Types:
6132
6133                 Node = node()
6134                 Fun = function()
6135
6136              Returns the process identifier (pid) of a new process started by
6137              the  application  of Fun to the empty list [] on Node. A link is
6138              created between the calling process and the new process,  atomi‐
6139              cally.  If Node does not exist, a useless pid is returned and an
6140              exit signal with reason noconnection  is  sent  to  the  calling
6141              process. Otherwise works like spawn/3.
6142
6143       spawn_link(Module, Function, Args) -> pid()
6144
6145              Types:
6146
6147                 Module = module()
6148                 Function = atom()
6149                 Args = [term()]
6150
6151              Returns  the  process identifier of a new process started by the
6152              application of  Module:Function  to  Args.  A  link  is  created
6153              between  the  calling  process  and the new process, atomically.
6154              Otherwise works like spawn/3.
6155
6156       spawn_link(Node, Module, Function, Args) -> pid()
6157
6158              Types:
6159
6160                 Node = node()
6161                 Module = module()
6162                 Function = atom()
6163                 Args = [term()]
6164
6165              Returns the process identifier (pid) of a new process started by
6166              the  application  of  Module:Function to Args on Node. A link is
6167              created between the calling process and the new process,  atomi‐
6168              cally.  If Node does not exist, a useless pid is returned and an
6169              exit signal with reason noconnection  is  sent  to  the  calling
6170              process. Otherwise works like spawn/3.
6171
6172       spawn_monitor(Fun) -> {pid(), reference()}
6173
6174              Types:
6175
6176                 Fun = function()
6177
6178              Returns  the process identifier of a new process, started by the
6179              application of Fun to the empty list [], and a reference  for  a
6180              monitor  created  to  the  new  process.  Otherwise  works  like
6181              spawn/3.
6182
6183       spawn_monitor(Node, Fun) -> {pid(), reference()}
6184
6185              Types:
6186
6187                 Node = node()
6188                 Fun = function()
6189
6190              Returns the process identifier of a new process, started by  the
6191              application  of Fun to the empty list [] on the node Node, and a
6192              reference for a monitor created to the  new  process.  Otherwise
6193              works like spawn/3.
6194
6195              If  the  node  identified  by  Node does not support distributed
6196              spawn_monitor(), the call will fail with a notsup exception.
6197
6198       spawn_monitor(Module, Function, Args) -> {pid(), reference()}
6199
6200              Types:
6201
6202                 Module = module()
6203                 Function = atom()
6204                 Args = [term()]
6205
6206              A new process is started by the application  of  Module:Function
6207              to  Args. The process is monitored at the same time. Returns the
6208              process identifier and a reference for  the  monitor.  Otherwise
6209              works like spawn/3.
6210
6211       spawn_monitor(Node, Module, Function, Args) ->
6212                        {pid(), reference()}
6213
6214              Types:
6215
6216                 Node = node()
6217                 Module = module()
6218                 Function = atom()
6219                 Args = [term()]
6220
6221              A  new  process is started by the application of Module:Function
6222              to Args on the node Node. The process is monitored at  the  same
6223              time.  Returns  the  process  identifier and a reference for the
6224              monitor. Otherwise works like spawn/3.
6225
6226              If the node identified by  Node  does  not  support  distributed
6227              spawn_monitor(), the call will fail with a notsup exception.
6228
6229       spawn_opt(Fun, Options) -> pid() | {pid(), reference()}
6230
6231              Types:
6232
6233                 Fun = function()
6234                 Options = [spawn_opt_option()]
6235                 priority_level() = low | normal | high | max
6236                 max_heap_size() =
6237                     integer() >= 0 |
6238                     #{size => integer() >= 0,
6239                       kill => boolean(),
6240                       error_logger => boolean()}
6241                 message_queue_data() = off_heap | on_heap
6242                 spawn_opt_option() =
6243                     link | monitor |
6244                     {priority, Level :: priority_level()} |
6245                     {fullsweep_after, Number :: integer() >= 0} |
6246                     {min_heap_size, Size :: integer() >= 0} |
6247                     {min_bin_vheap_size, VSize :: integer() >= 0} |
6248                     {max_heap_size, Size :: max_heap_size()} |
6249                     {message_queue_data, MQD :: message_queue_data()}
6250
6251              Returns the process identifier (pid) of a new process started by
6252              the application of Fun to the empty  list  [].  Otherwise  works
6253              like spawn_opt/4.
6254
6255              If  option  monitor  is  specified, the newly created process is
6256              monitored, and both the pid and reference for  the  monitor  are
6257              returned.
6258
6259       spawn_opt(Node, Fun, Options) -> pid() | {pid(), reference()}
6260
6261              Types:
6262
6263                 Node = node()
6264                 Fun = function()
6265                 Options = [monitor | link | OtherOption]
6266                 OtherOption = term()
6267
6268              Returns the process identifier (pid) of a new process started by
6269              the application of Fun to the empty list []  on  Node.  If  Node
6270              does  not exist, a useless pid is returned. Otherwise works like
6271              spawn_opt/4.
6272
6273              Valid options depends on what options are supported by the  node
6274              identified by Node. A description of valid Options for the local
6275              node of current OTP version can be found in the documentation of
6276              spawn_opt/4.
6277
6278       spawn_opt(Module, Function, Args, Options) ->
6279                    pid() | {pid(), reference()}
6280
6281              Types:
6282
6283                 Module = module()
6284                 Function = atom()
6285                 Args = [term()]
6286                 Options = [spawn_opt_option()]
6287                 priority_level() = low | normal | high | max
6288                 max_heap_size() =
6289                     integer() >= 0 |
6290                     #{size => integer() >= 0,
6291                       kill => boolean(),
6292                       error_logger => boolean()}
6293                 message_queue_data() = off_heap | on_heap
6294                 spawn_opt_option() =
6295                     link | monitor |
6296                     {priority, Level :: priority_level()} |
6297                     {fullsweep_after, Number :: integer() >= 0} |
6298                     {min_heap_size, Size :: integer() >= 0} |
6299                     {min_bin_vheap_size, VSize :: integer() >= 0} |
6300                     {max_heap_size, Size :: max_heap_size()} |
6301                     {message_queue_data, MQD :: message_queue_data()}
6302
6303              Works  as spawn/3, except that an extra option list is specified
6304              when creating the process.
6305
6306              If option monitor is specified, the  newly  created  process  is
6307              monitored,  and  both  the pid and reference for the monitor are
6308              returned.
6309
6310              Options:
6311
6312                link:
6313                  Sets a link to the parent process (like spawn_link/3 does).
6314
6315                monitor:
6316                  Monitors the new process (like monitor/2 does).
6317
6318                {priority, Level}:
6319                  Sets the priority of the new process. Equivalent to  execut‐
6320                  ing  process_flag(priority,  Level) in the start function of
6321                  the new process, except that the priority is set before  the
6322                  process  is  selected  for execution for the first time. For
6323                  more information on priorities,  see  process_flag(priority,
6324                  Level).
6325
6326                {fullsweep_after, Number}:
6327                  Useful  only  for performance tuning. Do not use this option
6328                  unless you know that there is problem with  execution  times
6329                  or  memory  consumption, and ensure that the option improves
6330                  matters.
6331
6332                  The Erlang runtime system uses a generational  garbage  col‐
6333                  lection  scheme,  using an "old heap" for data that has sur‐
6334                  vived at least one garbage collection. When there is no more
6335                  room  on  the  old  heap,  a fullsweep garbage collection is
6336                  done.
6337
6338                  Option fullsweep_after makes it possible to specify the max‐
6339                  imum  number  of  generational  collections before forcing a
6340                  fullsweep, even if there is room on the  old  heap.  Setting
6341                  the  number  to  zero  disables the general collection algo‐
6342                  rithm, that is, all live data is  copied  at  every  garbage
6343                  collection.
6344
6345                  A few cases when it can be useful to change fullsweep_after:
6346
6347                  * If  binaries that are no longer used are to be thrown away
6348                    as soon as possible. (Set Number to zero.)
6349
6350                  * A process that mostly have short-lived data is fullsweeped
6351                    seldom  or  never,  that  is, the old heap contains mostly
6352                    garbage. To ensure a fullsweep occasionally, set Number to
6353                    a suitable value, such as 10 or 20.
6354
6355                  * In  embedded  systems  with a limited amount of RAM and no
6356                    virtual memory, you might want to preserve memory by  set‐
6357                    ting  Number  to zero. (The value can be set globally, see
6358                    erlang:system_flag/2.)
6359
6360                {min_heap_size, Size}:
6361                  Useful only for performance tuning. Do not use  this  option
6362                  unless  you  know that there is problem with execution times
6363                  or memory consumption, and ensure that the  option  improves
6364                  matters.
6365
6366                  Gives  a  minimum  heap  size,  in words. Setting this value
6367                  higher than the system default can speed up  some  processes
6368                  because  less garbage collection is done. However, setting a
6369                  too high value can waste memory and  slow  down  the  system
6370                  because  of  worse data locality. Therefore, use this option
6371                  only for fine-tuning an application and to measure the  exe‐
6372                  cution time with various Size values.
6373
6374                {min_bin_vheap_size, VSize}:
6375                  Useful  only  for performance tuning. Do not use this option
6376                  unless you know that there is problem with  execution  times
6377                  or  memory  consumption, and ensure that the option improves
6378                  matters.
6379
6380                  Gives a minimum binary virtual heap size, in words.  Setting
6381                  this  value higher than the system default can speed up some
6382                  processes because less garbage collection is done.  However,
6383                  setting  a  too  high value can waste memory. Therefore, use
6384                  this option only for fine-tuning an application and to  mea‐
6385                  sure the execution time with various VSize values.
6386
6387                {max_heap_size, Size}:
6388                  Sets   the   max_heap_size   process   flag.   The   default
6389                  max_heap_size is determined by command-line  argument  +hmax
6390                  in  erl(1).  For  more information, see the documentation of
6391                  process_flag(max_heap_size, Size).
6392
6393                {message_queue_data, MQD}:
6394                  Sets the value of the message_queue_data process  flag.  MQD
6395                  can  be either off_heap or on_heap. The default value of the
6396                  message_queue_data process flag is determined  by  the  com‐
6397                  mand-line  argument  +hmqd  in erl(1). For more information,
6398                  see the  documentation  of  process_flag(message_queue_data,
6399                  MQD).
6400
6401       spawn_opt(Node, Module, Function, Args, Options) ->
6402                    pid() | {pid(), reference()}
6403
6404              Types:
6405
6406                 Node = node()
6407                 Module = module()
6408                 Function = atom()
6409                 Args = [term()]
6410                 Options = [monitor | link | OtherOption]
6411                 OtherOption = term()
6412
6413              Returns the process identifier (pid) of a new process started by
6414              the application of Module:Function to Args on Node. If Node does
6415              not  exist,  a  useless  pid  is  returned. Otherwise works like
6416              spawn_opt/4.
6417
6418              Valid options depends on what options are supported by the  node
6419              identified by Node. A description of valid Options for the local
6420              node of current OTP version can be found in the documentation of
6421              spawn_opt/4.
6422
6423       spawn_request(Fun) -> ReqId
6424
6425              Types:
6426
6427                 Fun = function()
6428                 ReqId = reference()
6429
6430              The  same  as  the call spawn_request(node(),Fun,[]). That is, a
6431              spawn request on the local node with no options.
6432
6433       spawn_request(Fun, Options) -> ReqId
6434
6435              Types:
6436
6437                 Fun = function()
6438                 Option =
6439                     {reply_tag,    ReplyTag}    |    {reply,     Reply}     |
6440                 spawn_opt_option()
6441                 ReplyTag = term()
6442                 Reply = yes | no | error_only | success_only
6443                 Options = [Option]
6444                 ReqId = reference()
6445
6446              The same as the call spawn_request(node(),Fun,Options). That is,
6447              a spawn request on the local node.
6448
6449       spawn_request(Node, Fun) -> ReqId
6450
6451              Types:
6452
6453                 Node = node()
6454                 Fun = function()
6455                 ReqId = reference()
6456
6457              The same as the  call  spawn_request(Node,Fun,[]).  That  is,  a
6458              spawn request with no options.
6459
6460       spawn_request(Node, Fun, Options) -> ReqId
6461
6462              Types:
6463
6464                 Node = node()
6465                 Fun = function()
6466                 Options = [Option]
6467                 Option =
6468                     monitor | link |
6469                     {reply_tag, ReplyTag} |
6470                     {reply, Reply} |
6471                     OtherOption
6472                 ReplyTag = term()
6473                 Reply = yes | no | error_only | success_only
6474                 OtherOption = term()
6475                 ReqId = reference()
6476
6477              The  same  as spawn_request(Node,erlang,apply,[Fun,[]],Options).
6478              That is, a spawn request using the fun  Fun  of  arity  zero  as
6479              entry point.
6480
6481              This function will fail with a badarg exception if:
6482
6483                * Node is not an atom.
6484
6485                * Fun is not a fun of arity zero.
6486
6487                * Options is not a proper list of terms.
6488
6489       spawn_request(Module, Function, Args) -> ReqId
6490
6491              Types:
6492
6493                 Module = module()
6494                 Function = atom()
6495                 Args = [term()]
6496                 ReqId = reference()
6497
6498              The   same   as   the   call   spawn_request(node(),Module,Func‐
6499              tion,Args,[]). That is, a spawn request on the local  node  with
6500              no options.
6501
6502       spawn_request(Node, Module, Function, Args) -> ReqId
6503
6504              Types:
6505
6506                 Node = node()
6507                 Module = module()
6508                 Function = atom()
6509                 Args = [term()]
6510                 ReqId = reference()
6511
6512              The    same    as   the   call   spawn_request(Node,Module,Func‐
6513              tion,Args,[]). That is, a spawn request with no options.
6514
6515       spawn_request(Module, Function, Args, Options) -> ReqId
6516
6517              Types:
6518
6519                 Module = module()
6520                 Function = atom()
6521                 Args = [term()]
6522                 Option =
6523                     {reply_tag,    ReplyTag}    |    {reply,     Reply}     |
6524                 spawn_opt_option()
6525                 ReplyTag = term()
6526                 Reply = yes | no | error_only | success_only
6527                 Options = [Option]
6528                 ReqId = reference()
6529
6530              The   same   as   the   call   spawn_request(node(),Module,Func‐
6531              tion,Args,Options). That is, a spawn request on the local node.
6532
6533       spawn_request(Node, Module, Function, Args, Options) -> ReqId
6534
6535              Types:
6536
6537                 Node = node()
6538                 Module = module()
6539                 Function = atom()
6540                 Args = [term()]
6541                 Options = [Option]
6542                 Option =
6543                     monitor | link |
6544                     {reply_tag, ReplyTag} |
6545                     {reply, Reply} |
6546                     OtherOption
6547                 ReplyTag = term()
6548                 Reply = yes | no | error_only | success_only
6549                 OtherOption = term()
6550                 ReqId = reference()
6551
6552              Asynchronously send a spawn request. Returns a  request  identi‐
6553              fier ReqId.
6554
6555              If the spawn operation succeeds, a new process is created on the
6556              node identified by Node. When a spawn  operation  succeeds,  the
6557              caller  will by default be sent a message on the form {ReplyTag,
6558              ReqId, ok, Pid} where Pid is the process identifier of the newly
6559              created process. Such a message is referred to as a success mes‐
6560              sage  below in  the  text.  ReplyTag  is  by  default  the  atom
6561              spawn_reply unless modified by the {reply_tag, ReplyTag} option.
6562              The new process is started by the application of Module:Function
6563              to Args.
6564
6565              The  spawn  operation  fails either if creation of a new process
6566              failed or if the spawn operation was interrupted by a connection
6567              failure.  When  a  spawn  operation  fails,  the  caller will by
6568              default be sent a message on the form {ReplyTag,  ReqId,  error,
6569              Reason}  where  Reason  is  the  error reason. Such a message is
6570              referred to as an error message  below in  the  text.  Currently
6571              the following spawn error Reasons are defined, but other reasons
6572              can appear at any time without prior notice:
6573
6574                badopt:
6575                  An invalid Option was passed as argument. Note that  differ‐
6576                  ent runtime systems may support different options.
6577
6578                notsup:
6579                  The  node  identified  by Node does not support spawn opera‐
6580                  tions issued by spawn_request().
6581
6582                noconnection:
6583                  Failure to set up a connection to  the  node  identified  by
6584                  Node  or  the  connection  to  that node was lost during the
6585                  spawn operation. In the case  the  connection  was  lost,  a
6586                  process may or may not have been created.
6587
6588                system_limit:
6589                  Could not create a new process due to that some system limit
6590                  was reached. Typically the process table was full.
6591
6592              Valid Options:
6593
6594                monitor:
6595                  In the absence of spawn operation failures, atomically  sets
6596                  up  a  monitor  to the newly created process. That is, as if
6597                  the calling process had called monitor(process,  Pid)  where
6598                  Pid  is the process identifier of the newly created process.
6599                  The ReqId returned by spawn_request() is also used as  moni‐
6600                  tor  reference  as  if it was returned from monitor(process,
6601                  Pid).
6602
6603                  The monitor will not be activated for  the  calling  process
6604                  until the spawn operation has succeeded. The monitor can not
6605                  be demonitored before the operation has succeeded. A  'DOWN'
6606                  message  for  the corresponding monitor is guaranteed not to
6607                  be delivered before a success message  that  corresponds  to
6608                  the spawn operation. If the spawn operation fails, no 'DOWN'
6609                  message will be delivered.
6610
6611                  If the connection between the nodes involved  in  the  spawn
6612                  operation  is  lost  during  the  spawn operation, the spawn
6613                  operation will fail with an error reason of noconnection.  A
6614                  new process may or may not have been created.
6615
6616                link:
6617                  In absence of spawn operation failures, atomically sets up a
6618                  link between the  calling  process  and  the  newly  created
6619                  process.  That  is,  as  if  the  calling process had called
6620                  link(Pid) where Pid is the process identifier of  the  newly
6621                  created process.
6622
6623                  The link will not be activated for the calling process until
6624                  the spawn operation has  succeeded.  The  link  can  not  be
6625                  removed  before  the operation has succeeded. An exit signal
6626                  due to the link is guaranteed not to be delivered  before  a
6627                  success message  that corresponds to the spawn operation. If
6628                  the spawn operation fails, no exit signal due  to  the  link
6629                  will be delivered to the caller of spawn_request().
6630
6631                  If  the  connection  between the nodes involved in the spawn
6632                  operation is lost during  the  spawn  operation,  the  spawn
6633                  operation  will fail with an error reason of noconnection. A
6634                  new process may or may not have been created. If it has been
6635                  created,  it  will  be delivered an exit signal with an exit
6636                  reason of noconnection.
6637
6638                {reply, Reply}:
6639                  Valid Reply values:
6640
6641                  yes:
6642                    A spawn reply message will be sent to the  caller  regard‐
6643                    less of whether the operation succeeds or not. If the call
6644                    to spawn_request() returns without  raising  an  exception
6645                    and  the reply option is set to yes, the caller is guaran‐
6646                    teed to be delivered either a success message  or an error
6647                    message . The reply option is by default set to yes.
6648
6649                  no:
6650                    No spawn reply message will be sent to the caller when the
6651                    spawn operation completes. This regardless of whether  the
6652                    operation succeeds or not.
6653
6654                  error_only:
6655                    No  spawn  reply message will be sent to the caller if the
6656                    spawn operation succeeds, but an error  message   will  be
6657                    sent to the caller if the operation fails.
6658
6659                  success_only:
6660                    No  spawn  reply message will be sent to the caller if the
6661                    spawn operation fails, but a success message  will be sent
6662                    to the caller if the operation succeeds.
6663
6664                {reply_tag, ReplyTag}:
6665                  Sets  the  reply  tag to ReplyTag in the reply message. That
6666                  is, in the success  or error  message that is  sent  to  the
6667                  caller  due to the spawn operation. The default reply tag is
6668                  the atom spawn_reply.
6669
6670                OtherOption:
6671                  Other valid options depends on what options are supported by
6672                  the  node  identified  by Node. A description of other valid
6673                  Options for the local node of current  OTP  version  can  be
6674                  found in the documentation of spawn_opt/4.
6675
6676              This function will fail with a badarg exception if:
6677
6678                * Node is not an atom.
6679
6680                * Module is not an atom.
6681
6682                * Function is not an atom.
6683
6684                * Args is not a proper list of terms.
6685
6686                * Options is not a proper list of terms.
6687
6688              Note  that not all individual Options are checked when the spawn
6689              request is sent. Some Options can only be checked  on  reception
6690              of  the  request.  Therefore  an invalid option does not cause a
6691              badarg exception, but will cause the  spawn  operation  to  fail
6692              with an error reason of badopt.
6693
6694              A  spawn request can be abandoned by calling spawn_request_aban‐
6695              don/1.
6696
6697       spawn_request_abandon(ReqId :: reference()) -> boolean()
6698
6699              Abandon a previously issued spawn request. ReqId corresponds  to
6700              a request identifier previously returned by spawn_request() in a
6701              call from current process. That is, only the  process  that  has
6702              made the request can abandon the request.
6703
6704              A  spawn  request  can  only be successfully abandoned until the
6705              spawn request has completed. When a spawn request has been  suc‐
6706              cessfully  abandoned,  the caller will not be effected by future
6707              direct effects of the spawn request itself. For example, it will
6708              not  receive  a  spawn reply message. The request is however not
6709              withdrawn, so a new process may or may not be created due to the
6710              request. If a new process is created after the spawn request was
6711              abandoned, no monitors nor links will be set up to the caller of
6712              spawn_request_abandon/1  due  to the spawn request. If the spawn
6713              request included the link option, the  process  created  due  to
6714              this  request  will  be sent an exit signal from its parent with
6715              the exit reason abandoned when it is  detected  that  the  spawn
6716              operation has succeeded.
6717
6718          Note:
6719              A process created due to a spawn request that has been abandoned
6720              may communicate with its parent as any other process. It is only
6721              the  direct  effects  on the parent of the actual spawn request,
6722              that will be canceled by abandoning a spawn request.
6723
6724
6725              Return values:
6726
6727                true:
6728                  The spawn request was successfully abandoned.
6729
6730                false:
6731                  No spawn request was abandoned. The ReqId request identifier
6732                  did not correspond to an outstanding spawn request issued by
6733                  the calling process. The reason for this is either:
6734
6735                  * ReqId corresponds to a spawn request  previoulsy  made  by
6736                    the calling process. The spawn operation has completed and
6737                    a spawn reply has already been delivered  to  the  calling
6738                    process  unless  the  spawn  reply  was  disabled  in  the
6739                    request.
6740
6741                  * ReqId does not correspond to a spawn request that has been
6742                    made by the calling process.
6743
6744              This  function  fail  with  a badarg exception if ReqId is not a
6745              reference.
6746
6747       split_binary(Bin, Pos) -> {binary(), binary()}
6748
6749              Types:
6750
6751                 Bin = binary()
6752                 Pos = integer() >= 0
6753                   0..byte_size(Bin)
6754
6755              Returns a tuple containing the binaries that are the  result  of
6756              splitting  Bin  into  two  parts  at position Pos. This is not a
6757              destructive operation. After  the  operation,  there  are  three
6758              binaries altogether. Example:
6759
6760              > B = list_to_binary("0123456789").
6761              <<"0123456789">>
6762              > byte_size(B).
6763              10
6764              > {B1, B2} = split_binary(B,3).
6765              {<<"012">>,<<"3456789">>}
6766              > byte_size(B1).
6767              3
6768              > byte_size(B2).
6769              7
6770
6771       erlang:start_timer(Time, Dest, Msg) -> TimerRef
6772
6773              Types:
6774
6775                 Time = integer() >= 0
6776                 Dest = pid() | atom()
6777                 Msg = term()
6778                 TimerRef = reference()
6779
6780              Starts  a  timer.  The  same as calling erlang:start_timer(Time,
6781              Dest, Msg, []).
6782
6783       erlang:start_timer(Time, Dest, Msg, Options) -> TimerRef
6784
6785              Types:
6786
6787                 Time = integer()
6788                 Dest = pid() | atom()
6789                 Msg = term()
6790                 Options = [Option]
6791                 Abs = boolean()
6792                 Option = {abs, Abs}
6793                 TimerRef = reference()
6794
6795              Starts a timer. When the timer expires,  the  message  {timeout,
6796              TimerRef, Msg} is sent to the process identified by Dest.
6797
6798              Options:
6799
6800                {abs, false}:
6801                  This  is the default. It means the Time value is interpreted
6802                  as a time in milliseconds relative current Erlang  monotonic
6803                  time.
6804
6805                {abs, true}:
6806                  Absolute  Time  value.  The  Time value is interpreted as an
6807                  absolute Erlang monotonic time in milliseconds.
6808
6809              More Options can be added in the future.
6810
6811              The absolute point in time, the timer is set to expire on,  must
6812              be  in the interval [erlang:system_info(start_time), erlang:sys‐
6813              tem_info(end_time)]. If a relative time is specified,  the  Time
6814              value is not allowed to be negative.
6815
6816              If  Dest  is a pid(), it must be a pid() of a process created on
6817              the current runtime system instance.  This  process  has  either
6818              terminated  or  not.  If Dest is an atom(), it is interpreted as
6819              the name of a locally registered process. The  process  referred
6820              to  by the name is looked up at the time of timer expiration. No
6821              error is returned if the name does not refer to a process.
6822
6823              If Dest is a pid(), the timer is automatically canceled  if  the
6824              process referred to by the pid() is not alive, or if the process
6825              exits. This feature was introduced in ERTS 5.4.11.  Notice  that
6826              timers are not automatically canceled when Dest is an atom().
6827
6828              See   also   erlang:send_after/4,   erlang:cancel_timer/2,   and
6829              erlang:read_timer/2.
6830
6831              Failure: badarg if the arguments do not satisfy the requirements
6832              specified here.
6833
6834       statistics(Item :: active_tasks) -> [ActiveTasks]
6835
6836              Types:
6837
6838                 ActiveTasks = integer() >= 0
6839
6840              Returns the same as statistics(active_tasks_all) with the excep‐
6841              tion that no information about the dirty IO run  queue  and  its
6842              associated schedulers is part of the result. That is, only tasks
6843              that are expected to be CPU bound are part of the result.
6844
6845       statistics(Item :: active_tasks_all) -> [ActiveTasks]
6846
6847              Types:
6848
6849                 ActiveTasks = integer() >= 0
6850
6851              Returns a list where  each  element  represents  the  amount  of
6852              active  processes and ports on each run queue and its associated
6853              schedulers. That is, the number of processes and ports that  are
6854              ready  to  run,  or are currently running. Values for normal run
6855              queues and their associated schedulers are located first in  the
6856              resulting  list. The first element corresponds to scheduler num‐
6857              ber 1 and so on. If support for dirty schedulers exist, an  ele‐
6858              ment  with the value for the dirty CPU run queue and its associ‐
6859              ated dirty CPU schedulers follow and then as  last  element  the
6860              value for the the dirty IO run queue and its associated dirty IO
6861              schedulers follow. The information is not  gathered  atomically.
6862              That  is, the result is not necessarily a consistent snapshot of
6863              the state, but instead quite efficiently gathered.
6864
6865          Note:
6866              Each normal scheduler has one run  queue  that  it  manages.  If
6867              dirty  schedulers schedulers are supported, all dirty CPU sched‐
6868              ulers share one run queue, and all dirty IO schedulers share one
6869              run  queue.  That  is,  we  have multiple normal run queues, one
6870              dirty CPU run queue and one dirty IO run  queue.  Work  can  not
6871              migrate  between the different types of run queues. Only work in
6872              normal run queues can migrate to other normal run  queues.  This
6873              has to be taken into account when evaluating the result.
6874
6875
6876              See       also      statistics(total_active_tasks),      statis‐
6877              tics(run_queue_lengths), statistics(run_queue_lengths_all), sta‐
6878              tistics(total_run_queue_lengths),           and          statis‐
6879              tics(total_run_queue_lengths_all).
6880
6881       statistics(Item :: context_switches) -> {ContextSwitches, 0}
6882
6883              Types:
6884
6885                 ContextSwitches = integer() >= 0
6886
6887              Returns the total number of context switches  since  the  system
6888              started.
6889
6890       statistics(Item :: exact_reductions) ->
6891                     {Total_Exact_Reductions,
6892                      Exact_Reductions_Since_Last_Call}
6893
6894              Types:
6895
6896                 Total_Exact_Reductions  =  Exact_Reductions_Since_Last_Call =
6897                 integer() >= 0
6898
6899              Returns the number of exact reductions.
6900
6901          Note:
6902              statistics(exact_reductions) is a more expensive operation  than
6903              statistics(reductions).
6904
6905
6906       statistics(Item :: garbage_collection) ->
6907                     {Number_of_GCs, Words_Reclaimed, 0}
6908
6909              Types:
6910
6911                 Number_of_GCs = Words_Reclaimed = integer() >= 0
6912
6913              Returns information about garbage collection, for example:
6914
6915              > statistics(garbage_collection).
6916              {85,23961,0}
6917
6918              This information can be invalid for some implementations.
6919
6920       statistics(Item :: io) -> {{input, Input}, {output, Output}}
6921
6922              Types:
6923
6924                 Input = Output = integer() >= 0
6925
6926              Returns  Input,  which  is  the  total  number of bytes received
6927              through ports, and Output, which is the total  number  of  bytes
6928              output to ports.
6929
6930       statistics(Item :: microstate_accounting) ->
6931                     [MSAcc_Thread] | undefined
6932
6933              Types:
6934
6935                 MSAcc_Thread =
6936                     #{type := MSAcc_Thread_Type,
6937                       id := MSAcc_Thread_Id,
6938                       counters := MSAcc_Counters}
6939                 MSAcc_Thread_Type =
6940                     async | aux | dirty_io_scheduler | dirty_cpu_scheduler |
6941                     poll | scheduler
6942                 MSAcc_Thread_Id = integer() >= 0
6943                 MSAcc_Counters = #{MSAcc_Thread_State => integer() >= 0}
6944                 MSAcc_Thread_State =
6945                     alloc | aux | bif | busy_wait | check_io | emulator | ets
6946                 |
6947                     gc | gc_fullsweep | nif | other | port | send |  sleep  |
6948                 timers
6949
6950              Microstate  accounting  can be used to measure how much time the
6951              Erlang runtime system spends doing various tasks. It is designed
6952              to  be as lightweight as possible, but some overhead exists when
6953              this is enabled. Microstate accounting is meant to be a  profil‐
6954              ing   tool   to   help   finding   performance  bottlenecks.  To
6955              start/stop/reset  microstate   accounting,   use   system   flag
6956              microstate_accounting.
6957
6958              statistics(microstate_accounting)  returns a list of maps repre‐
6959              senting some of the OS threads within ERTS.  Each  map  contains
6960              type  and  id fields that can be used to identify what thread it
6961              is, and also a counters field that contains data about how  much
6962              time has been spent in the various states.
6963
6964              Example:
6965
6966              > erlang:statistics(microstate_accounting).
6967              [#{counters => #{aux => 1899182914,
6968                               check_io => 2605863602,
6969                               emulator => 45731880463,
6970                               gc => 1512206910,
6971                               other => 5421338456,
6972                               port => 221631,
6973                               sleep => 5150294100},
6974                 id => 1,
6975                 type => scheduler}|...]
6976
6977              The  time unit is the same as returned by os:perf_counter/0. So,
6978              to convert it to milliseconds, you can do something like this:
6979
6980              lists:map(
6981                fun(#{ counters := Cnt } = M) ->
6982                        MsCnt = maps:map(fun(_K, PerfCount) ->
6983                                                 erlang:convert_time_unit(PerfCount, perf_counter, 1000)
6984                                         end, Cnt),
6985                       M#{ counters := MsCnt }
6986                end, erlang:statistics(microstate_accounting)).
6987
6988              Notice that these values are not guaranteed to be the exact time
6989              spent  in  each  state.  This is because of various optimisation
6990              done to keep the overhead as small as possible.
6991
6992              MSAcc_Thread_Types:
6993
6994                scheduler:
6995                  The main execution threads that do most of the work. See erl
6996                  +S for more details.
6997
6998                dirty_cpu_scheduler:
6999                  The  threads  for  long  running cpu intensive work. See erl
7000                  +SDcpu for more details.
7001
7002                dirty_io_scheduler:
7003                  The threads for long running I/O work.  See  erl  +SDio  for
7004                  more details.
7005
7006                async:
7007                  Async  threads are used by various linked-in drivers (mainly
7008                  the file drivers) do offload non-CPU intensive work. See erl
7009                  +A for more details.
7010
7011                aux:
7012                  Takes  care of any work that is not specifically assigned to
7013                  a scheduler.
7014
7015                poll:
7016                  Does the IO polling for the emulator. See erl +IOt for  more
7017                  details.
7018
7019              The  following MSAcc_Thread_States are available. All states are
7020              exclusive, meaning that a thread cannot  be  in  two  states  at
7021              once.  So,  if  you add the numbers of all counters in a thread,
7022              you get the total runtime for that thread.
7023
7024                aux:
7025                  Time spent handling auxiliary jobs.
7026
7027                check_io:
7028                  Time spent checking for new I/O events.
7029
7030                emulator:
7031                  Time spent executing Erlang processes.
7032
7033                gc:
7034                  Time spent doing garbage collection. When extra  states  are
7035                  enabled  this  is the time spent doing non-fullsweep garbage
7036                  collections.
7037
7038                other:
7039                  Time spent doing unaccounted things.
7040
7041                port:
7042                  Time spent executing ports.
7043
7044                sleep:
7045                  Time spent sleeping.
7046
7047              More fine-grained MSAcc_Thread_States can be added through  con‐
7048              figure (such as ./configure --with-microstate-accounting=extra).
7049              Enabling  these  states  causes  performance  degradation   when
7050              microstate  accounting  is turned off and increases the overhead
7051              when it is turned on.
7052
7053                alloc:
7054                  Time spent managing memory. Without extra states  this  time
7055                  is spread out over all other states.
7056
7057                bif:
7058                  Time  spent  in BIFs. Without extra states this time is part
7059                  of the emulator state.
7060
7061                busy_wait:
7062                  Time spent busy waiting. This is  also  the  state  where  a
7063                  scheduler  no  longer  reports  that it is active when using
7064                  statistics(scheduler_wall_time). So, if you  add  all  other
7065                  states  but this and sleep, and then divide that by all time
7066                  in the thread, you should get something very similar to  the
7067                  scheduler_wall_time fraction. Without extra states this time
7068                  is part of the other state.
7069
7070                ets:
7071                  Time spent executing ETS BIFs.  Without  extra  states  this
7072                  time is part of the emulator state.
7073
7074                gc_full:
7075                  Time spent doing fullsweep garbage collection. Without extra
7076                  states this time is part of the gc state.
7077
7078                nif:
7079                  Time spent in NIFs. Without extra states this time  is  part
7080                  of the emulator state.
7081
7082                send:
7083                  Time  spent sending messages (processes only). Without extra
7084                  states this time is part of the emulator state.
7085
7086                timers:
7087                  Time spent managing timers. Without extra states  this  time
7088                  is part of the other state.
7089
7090              The  utility  module msacc(3) can be used to more easily analyse
7091              these statistics.
7092
7093              Returns undefined if system flag microstate_accounting is turned
7094              off.
7095
7096              The  list  of  thread  information is unsorted and can appear in
7097              different order between calls.
7098
7099          Note:
7100              The threads and states are subject to change without  any  prior
7101              notice.
7102
7103
7104       statistics(Item :: reductions) ->
7105                     {Total_Reductions, Reductions_Since_Last_Call}
7106
7107              Types:
7108
7109                 Total_Reductions  = Reductions_Since_Last_Call = integer() >=
7110                 0
7111
7112              Returns information about reductions, for example:
7113
7114              > statistics(reductions).
7115              {2046,11}
7116
7117          Note:
7118              As from ERTS 5.5 (Erlang/OTP R11B), this value does not  include
7119              reductions  performed in current time slices of currently sched‐
7120              uled processes.  If  an  exact  value  is  wanted,  use  statis‐
7121              tics(exact_reductions).
7122
7123
7124       statistics(Item :: run_queue) -> integer() >= 0
7125
7126              Returns the total length of all normal and dirty CPU run queues.
7127              That is, queued work that is  expected  to  be  CPU  bound.  The
7128              information  is  gathered  atomically.  That is, the result is a
7129              consistent snapshot of the state, but  this  operation  is  much
7130              more  expensive compared to statistics(total_run_queue_lengths),
7131              especially when a large amount of schedulers is used.
7132
7133       statistics(Item :: run_queue_lengths) -> [RunQueueLength]
7134
7135              Types:
7136
7137                 RunQueueLength = integer() >= 0
7138
7139              Returns the same as statistics(run_queue_lengths_all)  with  the
7140              exception  that  no  information about the dirty IO run queue is
7141              part of the result. That is, only run queues with work  that  is
7142              expected to be CPU bound is part of the result.
7143
7144       statistics(Item :: run_queue_lengths_all) -> [RunQueueLength]
7145
7146              Types:
7147
7148                 RunQueueLength = integer() >= 0
7149
7150              Returns  a list where each element represents the amount of pro‐
7151              cesses and ports ready to run for each  run  queue.  Values  for
7152              normal  run  queues are located first in the resulting list. The
7153              first element corresponds to the normal run queue  of  scheduler
7154              number  1 and so on. If support for dirty schedulers exist, val‐
7155              ues for the dirty CPU run queue and the dirty IO run queue  fol‐
7156              low  (in that order) at the end. The information is not gathered
7157              atomically. That is, the result is not necessarily a  consistent
7158              snapshot of the state, but instead quite efficiently gathered.
7159
7160          Note:
7161              Each  normal  scheduler  has  one  run queue that it manages. If
7162              dirty schedulers schedulers are supported, all dirty CPU  sched‐
7163              ulers share one run queue, and all dirty IO schedulers share one
7164              run queue. That is, we have  multiple  normal  run  queues,  one
7165              dirty  CPU  run  queue  and one dirty IO run queue. Work can not
7166              migrate between the different types of run queues. Only work  in
7167              normal  run  queues can migrate to other normal run queues. This
7168              has to be taken into account when evaluating the result.
7169
7170
7171              See      also       statistics(run_queue_lengths),       statis‐
7172              tics(total_run_queue_lengths_all),                       statis‐
7173              tics(total_run_queue_lengths), statistics(active_tasks), statis‐
7174              tics(active_tasks_all), and statistics(total_active_tasks), sta‐
7175              tistics(total_active_tasks_all).
7176
7177       statistics(Item :: runtime) ->
7178                     {Total_Run_Time, Time_Since_Last_Call}
7179
7180              Types:
7181
7182                 Total_Run_Time = Time_Since_Last_Call = integer() >= 0
7183
7184              Returns information about runtime, in milliseconds.
7185
7186              This is the sum of the runtime for all  threads  in  the  Erlang
7187              runtime  system and can therefore be greater than the wall clock
7188              time.
7189
7190          Warning:
7191              This value might wrap due to limitations in the underlying func‐
7192              tionality provided by the operating system that is used.
7193
7194
7195              Example:
7196
7197              > statistics(runtime).
7198              {1690,1620}
7199
7200       statistics(Item :: scheduler_wall_time) ->
7201                     [{SchedulerId, ActiveTime, TotalTime}] | undefined
7202
7203              Types:
7204
7205                 SchedulerId = integer() >= 1
7206                 ActiveTime = TotalTime = integer() >= 0
7207
7208              Returns  a  list of tuples with {SchedulerId, ActiveTime, Total‐
7209              Time}, where SchedulerId is an  integer  ID  of  the  scheduler,
7210              ActiveTime  is  the  duration  the  scheduler has been busy, and
7211              TotalTime is the total time duration  since  scheduler_wall_time
7212              activation for the specific scheduler. Note that activation time
7213              can differ significantly  between  schedulers.  Currently  dirty
7214              schedulers are activated at system start while normal schedulers
7215              are activated some time after the scheduler_wall_time  function‐
7216              ality  is enabled. The time unit is undefined and can be subject
7217              to change between releases, OSs,  and  system  restarts.  sched‐
7218              uler_wall_time  is  only to be used to calculate relative values
7219              for scheduler utilization. ActiveTime can  never  exceed  Total‐
7220              Time.
7221
7222              The definition of a busy scheduler is when it is not idle and is
7223              not scheduling (selecting) a process or port, that is:
7224
7225                * Executing process code
7226
7227                * Executing linked-in driver or NIF code
7228
7229                * Executing BIFs, or any other runtime handling
7230
7231                * Garbage collecting
7232
7233                * Handling any other memory management
7234
7235              Notice that a scheduler can also be busy  even  if  the  OS  has
7236              scheduled out the scheduler thread.
7237
7238              Returns  undefined  if system flag scheduler_wall_time is turned
7239              off.
7240
7241              The list of scheduler information is unsorted and can appear  in
7242              different order between calls.
7243
7244              As  of  ERTS  version  9.0,  also  dirty  CPU schedulers will be
7245              included in the result. That is, all scheduler threads that  are
7246              expected  to handle CPU bound work. If you also want information
7247              about    dirty    I/O    schedulers,    use    statistics(sched‐
7248              uler_wall_time_all) instead.
7249
7250              Normal schedulers will have scheduler identifiers in the range 1
7251              =<  SchedulerId  =<  erlang:system_info(schedulers).  Dirty  CPU
7252              schedulers   will   have  scheduler  identifiers  in  the  range
7253              erlang:system_info(schedulers)  <  SchedulerId  =<   erlang:sys‐
7254              tem_info(schedulers) + erlang:system_info(dirty_cpu_schedulers).
7255
7256          Note:
7257              The different types of schedulers handle specific types of jobs.
7258              Every job is assigned to a specific  scheduler  type.  Jobs  can
7259              migrate between different schedulers of the same type, but never
7260              between schedulers of different types. This fact has to be taken
7261              under consideration when evaluating the result returned.
7262
7263
7264              Using scheduler_wall_time to calculate scheduler utilization:
7265
7266              > erlang:system_flag(scheduler_wall_time, true).
7267              false
7268              > Ts0 = lists:sort(erlang:statistics(scheduler_wall_time)), ok.
7269              ok
7270
7271              Some  time  later the user takes another snapshot and calculates
7272              scheduler utilization per scheduler, for example:
7273
7274              > Ts1 = lists:sort(erlang:statistics(scheduler_wall_time)), ok.
7275              ok
7276              > lists:map(fun({{I, A0, T0}, {I, A1, T1}}) -> {I, (A1 - A0)/(T1 - T0)} end, lists:zip(Ts0,Ts1)).
7277              [{1,0.9743474730177548},
7278               {2,0.9744843782751444},
7279               {3,0.9995902361669045},
7280               {4,0.9738012596572161},
7281               {5,0.9717956667018103},
7282               {6,0.9739235846420741},
7283               {7,0.973237033077876},
7284               {8,0.9741297293248656}]
7285
7286              Using the same snapshots to calculate a total scheduler utiliza‐
7287              tion:
7288
7289              > {A, T} = lists:foldl(fun({{_, A0, T0}, {_, A1, T1}}, {Ai,Ti}) -> {Ai + (A1 - A0), Ti + (T1 - T0)} end, {0, 0}, lists:zip(Ts0,Ts1)), TotalSchedulerUtilization = A/T.
7290              0.9769136803764825
7291
7292              Total  scheduler  utilization will equal 1.0 when all schedulers
7293              have been active all the time between the two measurements.
7294
7295              Another (probably more)  useful  value  is  to  calculate  total
7296              scheduler  utilization weighted against maximum amount of avail‐
7297              able CPU time:
7298
7299              > WeightedSchedulerUtilization = (TotalSchedulerUtilization * (erlang:system_info(schedulers) + erlang:system_info(dirty_cpu_schedulers))) / erlang:system_info(logical_processors_available).
7300              0.9769136803764825
7301
7302              This weighted scheduler utilization will reach 1.0  when  sched‐
7303              ulers  are  active  the same amount of time as maximum available
7304              CPU time. If more schedulers exist than available  logical  pro‐
7305              cessors, this value may be greater than 1.0.
7306
7307              As  of  ERTS  version  9.0,  the  Erlang  runtime system will as
7308              default have more schedulers than logical processors.  This  due
7309              to the dirty schedulers.
7310
7311          Note:
7312              scheduler_wall_time  is  by  default disabled. To enable it, use
7313              erlang:system_flag(scheduler_wall_time, true).
7314
7315
7316       statistics(Item :: scheduler_wall_time_all) ->
7317                     [{SchedulerId, ActiveTime, TotalTime}] | undefined
7318
7319              Types:
7320
7321                 SchedulerId = integer() >= 1
7322                 ActiveTime = TotalTime = integer() >= 0
7323
7324              The same as statistics(scheduler_wall_time), except that it also
7325              include information about all dirty I/O schedulers.
7326
7327              Dirty IO schedulers will have scheduler identifiers in the range
7328              erlang:system_info(schedulers)           +           erlang:sys‐
7329              tem_info(dirty_cpu_schedulers)   <  SchedulerId  =<  erlang:sys‐
7330              tem_info(schedulers) +  erlang:system_info(dirty_cpu_schedulers)
7331              + erlang:system_info(dirty_io_schedulers).
7332
7333          Note:
7334              Note that work executing on dirty I/O schedulers are expected to
7335              mainly wait for I/O. That is, when you get high  scheduler  uti‐
7336              lization  on  dirty  I/O  schedulers,  CPU  utilization  is  not
7337              expected to be high due to this work.
7338
7339
7340       statistics(Item :: total_active_tasks) -> ActiveTasks
7341
7342              Types:
7343
7344                 ActiveTasks = integer() >= 0
7345
7346              The same  as  calling  lists:sum(statistics(active_tasks)),  but
7347              more efficient.
7348
7349       statistics(Item :: total_active_tasks_all) -> ActiveTasks
7350
7351              Types:
7352
7353                 ActiveTasks = integer() >= 0
7354
7355              The same as calling lists:sum(statistics(active_tasks_all)), but
7356              more efficient.
7357
7358       statistics(Item :: total_run_queue_lengths) ->
7359                     TotalRunQueueLengths
7360
7361              Types:
7362
7363                 TotalRunQueueLengths = integer() >= 0
7364
7365              The same  as  calling  lists:sum(statistics(run_queue_lengths)),
7366              but more efficient.
7367
7368       statistics(Item :: total_run_queue_lengths_all) ->
7369                     TotalRunQueueLengths
7370
7371              Types:
7372
7373                 TotalRunQueueLengths = integer() >= 0
7374
7375              The        same        as        calling       lists:sum(statis‐
7376              tics(run_queue_lengths_all)), but more efficient.
7377
7378       statistics(Item :: wall_clock) ->
7379                     {Total_Wallclock_Time,
7380                      Wallclock_Time_Since_Last_Call}
7381
7382              Types:
7383
7384                 Total_Wallclock_Time = Wallclock_Time_Since_Last_Call = inte‐
7385                 ger() >= 0
7386
7387              Returns  information about wall clock. wall_clock can be used in
7388              the same manner as runtime, except that real time is measured as
7389              opposed to runtime or CPU time.
7390
7391       erlang:suspend_process(Suspendee) -> true
7392
7393              Types:
7394
7395                 Suspendee = pid()
7396
7397              Suspends  the process identified by Suspendee. The same as call‐
7398              ing erlang:suspend_process(Suspendee, []).
7399
7400          Warning:
7401              This BIF is intended for debugging only.
7402
7403
7404       erlang:suspend_process(Suspendee, OptList) -> boolean()
7405
7406              Types:
7407
7408                 Suspendee = pid()
7409                 OptList = [Opt]
7410                 Opt  =  unless_suspending  |  asynchronous  |  {asynchronous,
7411                 term()}
7412
7413              Increases  the  suspend  count on the process identified by Sus‐
7414              pendee and puts it in the suspended state if it is  not  already
7415              in  that  state. A suspended process is not scheduled for execu‐
7416              tion until the process has been resumed.
7417
7418              A process can be suspended by multiple processes and can be sus‐
7419              pended  multiple  times by a single process. A suspended process
7420              does not leave the  suspended  state  until  its  suspend  count
7421              reaches  zero.  The suspend count of Suspendee is decreased when
7422              erlang:resume_process(Suspendee) is called by the  same  process
7423              that  called  erlang:suspend_process(Suspendee).  All  increased
7424              suspend counts on other processes  acquired  by  a  process  are
7425              automatically decreased when the process terminates.
7426
7427              Options (Opts):
7428
7429                asynchronous:
7430                  A  suspend request is sent to the process identified by Sus‐
7431                  pendee. Suspendee eventually suspends unless it  is  resumed
7432                  before   it   could   suspend.  The  caller  of  erlang:sus‐
7433                  pend_process/2 returns immediately,  regardless  of  whether
7434                  Suspendee  has  suspended yet or not. The point in time when
7435                  Suspendee suspends cannot be deduced from  other  events  in
7436                  the  system. It is only guaranteed that Suspendee eventually
7437                  suspends (unless it is resumed). If no asynchronous  options
7438                  has  been  passed, the caller of erlang:suspend_process/2 is
7439                  blocked until Suspendee has suspended.
7440
7441                {asynchronous, ReplyTag}:
7442                  A suspend request is sent to the process identified by  Sus‐
7443                  pendee. When the suspend request has been processed, a reply
7444                  message is sent to the caller of this function. The reply is
7445                  on the form {ReplyTag, State} where State is either:
7446
7447                  exited:
7448                    Suspendee has exited.
7449
7450                  suspended:
7451                    Suspendee is now suspended.
7452
7453                  not_suspended:
7454                    Suspendee  is not suspended. This can only happen when the
7455                    process   that   issued   this   request,   have    called
7456                    resume_process(Suspendee) before getting the reply.
7457
7458                  Appart  from the reply message, the {asynchronous, ReplyTag}
7459                  option behaves exactly the same as the  asynchronous  option
7460                  without reply tag.
7461
7462                unless_suspending:
7463                  The  process identified by Suspendee is suspended unless the
7464                  calling  process  already  is   suspending   Suspendee.   If
7465                  unless_suspending  is  combined  with option asynchronous, a
7466                  suspend request is sent unless the calling  process  already
7467                  is  suspending Suspendee or if a suspend request already has
7468                  been sent and is in transit. If the calling process  already
7469                  is  suspending  Suspendee,  or if combined with option asyn‐
7470                  chronous and a send request already is in transit, false  is
7471                  returned   and   the  suspend  count  on  Suspendee  remains
7472                  unchanged.
7473
7474              If the suspend count on the process identified by  Suspendee  is
7475              increased, true is returned, otherwise false.
7476
7477          Warning:
7478              This BIF is intended for debugging only.
7479
7480
7481          Warning:
7482              You can easily create deadlocks if processes suspends each other
7483              (directly or in circles). In ERTS versions prior to ERTS version
7484              10.0, the runtime system prevented such deadlocks, but this pre‐
7485              vention has now been removed due to performance reasons.
7486
7487
7488              Failures:
7489
7490                badarg:
7491                   If Suspendee is not a process identifier.
7492
7493                badarg:
7494                   If the process identified by Suspendee is the same  process
7495                  as the process calling erlang:suspend_process/2.
7496
7497                badarg:
7498                   If the process identified by Suspendee is not alive.
7499
7500                badarg:
7501                   If  the  process identified by Suspendee resides on another
7502                  node.
7503
7504                badarg:
7505                   If OptList is not a proper list of valid Opts.
7506
7507                system_limit:
7508                   If the process identified by Suspendee has  been  suspended
7509                  more times by the calling process than can be represented by
7510                  the currently used  internal  data  structures.  The  system
7511                  limit  is greater than 2,000,000,000 suspends and will never
7512                  be lower.
7513
7514       erlang:system_flag(Flag :: backtrace_depth, Depth) -> OldDepth
7515
7516              Types:
7517
7518                 Depth = OldDepth = integer() >= 0
7519
7520              Sets the maximum depth of call stack  back-traces  in  the  exit
7521              reason element of 'EXIT' tuples. The flag also limits the stack‐
7522              trace depth returned by process_info item current_stacktrace.
7523
7524              Returns the old value of the flag.
7525
7526       erlang:system_flag(Flag :: cpu_topology, CpuTopology) ->
7527                             OldCpuTopology
7528
7529              Types:
7530
7531                 CpuTopology = OldCpuTopology = cpu_topology()
7532                 cpu_topology() = [LevelEntry :: level_entry()] | undefined
7533                 level_entry() =
7534                     {LevelTag :: level_tag(), SubLevel :: sub_level()} |
7535                     {LevelTag :: level_tag(),
7536                      InfoList :: info_list(),
7537                      SubLevel :: sub_level()}
7538                 level_tag() = core | node | processor | thread
7539                 sub_level() =
7540                     [LevelEntry :: level_entry()] |
7541                     (LogicalCpuId :: {logical, integer() >= 0})
7542                 info_list() = []
7543
7544          Warning:
7545              This argument is deprecated. Instead of using this argument, use
7546              command-line argument +sct in erl(1).
7547
7548              When  this  argument  is removed, a final CPU topology to use is
7549              determined at emulator boot time.
7550
7551
7552              Sets the user-defined CpuTopology. The user-defined CPU topology
7553              overrides  any  automatically  detected CPU topology. By passing
7554              undefined as CpuTopology, the system reverts to the CPU topology
7555              automatically  detected.  The  returned  value  equals the value
7556              returned from erlang:system_info(cpu_topology) before the change
7557              was made.
7558
7559              Returns the old value of the flag.
7560
7561              The CPU topology is used when binding schedulers to logical pro‐
7562              cessors. If schedulers are already bound when the  CPU  topology
7563              is  changed, the schedulers are sent a request to rebind accord‐
7564              ing to the new CPU topology.
7565
7566              The user-defined CPU topology can also be set  by  passing  com‐
7567              mand-line argument +sct to erl(1).
7568
7569              For  information  on  type CpuTopology and more, see erlang:sys‐
7570              tem_info(cpu_topology) as well as command-line  flags  +sct  and
7571              +sbt in erl(1).
7572
7573       erlang:system_flag(Flag :: dirty_cpu_schedulers_online,
7574                          DirtyCPUSchedulersOnline) ->
7575                             OldDirtyCPUSchedulersOnline
7576
7577              Types:
7578
7579                 DirtyCPUSchedulersOnline   =   OldDirtyCPUSchedulersOnline  =
7580                 integer() >= 1
7581
7582              Sets the number of dirty CPU schedulers online. Range  is  1  <=
7583              DirtyCPUSchedulersOnline  <=  N,  where N is the smallest of the
7584              return values  of  erlang:system_info(dirty_cpu_schedulers)  and
7585              erlang:system_info(schedulers_online).
7586
7587              Returns the old value of the flag.
7588
7589              The number of dirty CPU schedulers online can change if the num‐
7590              ber of schedulers online changes. For example, if 12  schedulers
7591              and 6 dirty CPU schedulers are online, and system_flag/2 is used
7592              to set the number of schedulers online to 6, then the number  of
7593              dirty  CPU  schedulers online is automatically decreased by half
7594              as well, down to 3. Similarly, the number of  dirty  CPU  sched‐
7595              ulers online increases proportionally to increases in the number
7596              of schedulers online.
7597
7598              For more  information,  see  erlang:system_info(dirty_cpu_sched‐
7599              ulers) and erlang:system_info(dirty_cpu_schedulers_online).
7600
7601       erlang:system_flag(Flag :: erts_alloc, Value :: {Alloc, F, V}) ->
7602                             ok | notsup
7603
7604              Types:
7605
7606                 Alloc = F = atom()
7607                 V = integer()
7608
7609              Sets  system  flags for erts_alloc(3). Alloc is the allocator to
7610              affect, for example binary_alloc. F is the flag to change and  V
7611              is the new value.
7612
7613              Only  a  subset  of  all  erts_alloc flags can be changed at run
7614              time. This subset is currently only the flag sbct.
7615
7616              Returns ok if the flag was set or notsup  if  not  supported  by
7617              erts_alloc.
7618
7619       erlang:system_flag(Flag :: fullsweep_after, Number) -> OldNumber
7620
7621              Types:
7622
7623                 Number = OldNumber = integer() >= 0
7624
7625              Sets system flag fullsweep_after. Number is a non-negative inte‐
7626              ger indicating how many times generational  garbage  collections
7627              can  be  done  without forcing a fullsweep collection. The value
7628              applies to new processes, while processes  already  running  are
7629              not affected.
7630
7631              Returns the old value of the flag.
7632
7633              In  low-memory systems (especially without virtual memory), set‐
7634              ting the value to 0 can help to conserve memory.
7635
7636              This value can also be set  through  (OS)  environment  variable
7637              ERL_FULLSWEEP_AFTER.
7638
7639       erlang:system_flag(Flag :: microstate_accounting, Action) ->
7640                             OldState
7641
7642              Types:
7643
7644                 Action = true | false | reset
7645                 OldState = true | false
7646
7647              Turns  on/off  microstate  accounting measurements. When passing
7648              reset, all counters are reset to 0.
7649
7650              For more information see statistics(microstate_accounting).
7651
7652       erlang:system_flag(Flag :: min_heap_size, MinHeapSize) ->
7653                             OldMinHeapSize
7654
7655              Types:
7656
7657                 MinHeapSize = OldMinHeapSize = integer() >= 0
7658
7659              Sets the default minimum heap size for processes.  The  size  is
7660              specified in words. The new min_heap_size effects only processes
7661              spawned  after  the  change  of  min_heap_size  has  been  made.
7662              min_heap_size  can  be  set  for  individual  processes by using
7663              spawn_opt/4 or process_flag/2.
7664
7665              Returns the old value of the flag.
7666
7667       erlang:system_flag(Flag :: min_bin_vheap_size, MinBinVHeapSize) ->
7668                             OldMinBinVHeapSize
7669
7670              Types:
7671
7672                 MinBinVHeapSize = OldMinBinVHeapSize = integer() >= 0
7673
7674              Sets the default minimum binary virtual heap size for processes.
7675              The  size  is  specified  in  words. The new min_bin_vhheap_size
7676              effects   only   processes   spawned   after   the   change   of
7677              min_bin_vheap_size  has been made. min_bin_vheap_size can be set
7678              for   individual   processes   by   using   spawn_opt/2,3,4   or
7679              process_flag/2.
7680
7681              Returns the old value of the flag.
7682
7683       erlang:system_flag(Flag :: max_heap_size, MaxHeapSize) ->
7684                             OldMaxHeapSize
7685
7686              Types:
7687
7688                 MaxHeapSize = OldMaxHeapSize = max_heap_size()
7689                 max_heap_size() =
7690                     integer() >= 0 |
7691                     #{size => integer() >= 0,
7692                       kill => boolean(),
7693                       error_logger => boolean()}
7694
7695              Sets  the  default maximum heap size settings for processes. The
7696              size is specified in words. The new max_heap_size  effects  only
7697              processes  spawned efter the change has been made. max_heap_size
7698              can be set for individual  processes  using  spawn_opt/2,3,4  or
7699              process_flag/2.
7700
7701              Returns the old value of the flag.
7702
7703       erlang:system_flag(Flag :: multi_scheduling, BlockState) ->
7704                             OldBlockState
7705
7706              Types:
7707
7708                 BlockState = block | unblock | block_normal | unblock_normal
7709                 OldBlockState = blocked | disabled | enabled
7710
7711              If  multi-scheduling  is enabled, more than one scheduler thread
7712              is used by the emulator. Multi-scheduling can be blocked in  two
7713              different ways. Either all schedulers but one is blocked, or all
7714              normal schedulers but one is blocked. When  only  normal  sched‐
7715              ulers  are  blocked,  dirty  schedulers  are free to continue to
7716              schedule processes.
7717
7718              If BlockState =:= block, multi-scheduling is blocked.  That  is,
7719              one  and  only  one scheduler thread will execute. If BlockState
7720              =:= unblock and no one else blocks  multi-scheduling,  and  this
7721              process has blocked only once, multi-scheduling is unblocked.
7722
7723              If  BlockState  =:=  block_normal,  normal  multi-scheduling  is
7724              blocked. That is, only one normal scheduler thread will execute,
7725              but  multiple  dirty  schedulers  can execute. If BlockState =:=
7726              unblock_normal and no one else blocks  normal  multi-scheduling,
7727              and  this process has blocked only once, normal multi-scheduling
7728              is unblocked.
7729
7730              One process can block multi-scheduling and normal multi-schedul‐
7731              ing  multiple times. If a process has blocked multiple times, it
7732              must unblock exactly as many times as it has blocked  before  it
7733              has  released  its multi-scheduling block. If a process that has
7734              blocked multi-scheduling or normal  multi-scheduling  exits,  it
7735              automatically releases its blocking of multi-scheduling and nor‐
7736              mal multi-scheduling.
7737
7738              The return values  are  disabled,  blocked,  blocked_normal,  or
7739              enabled.  The  returned value describes the state just after the
7740              call  to  erlang:system_flag(multi_scheduling,  BlockState)  has
7741              been   made.  For  information  about  the  return  values,  see
7742              erlang:system_info(multi_scheduling).
7743
7744          Note:
7745              Blocking of multi-scheduling and normal multi-scheduling is nor‐
7746              mally  not  needed.  If you feel that you need to use these fea‐
7747              tures, consider it a few more times again. Blocking multi-sched‐
7748              uling  is only to be used as a last resort, as it is most likely
7749              a very inefficient way to solve the problem.
7750
7751
7752              See   also   erlang:system_info(multi_scheduling),   erlang:sys‐
7753              tem_info(normal_multi_scheduling_blockers),          erlang:sys‐
7754              tem_info(multi_scheduling_blockers),       and       erlang:sys‐
7755              tem_info(schedulers).
7756
7757       erlang:system_flag(Flag :: scheduler_bind_type, How) ->
7758                             OldBindType
7759
7760              Types:
7761
7762                 How = scheduler_bind_type() | default_bind
7763                 OldBindType = scheduler_bind_type()
7764                 scheduler_bind_type() =
7765                     no_node_processor_spread | no_node_thread_spread | no_spread |
7766                     processor_spread | spread | thread_spread |
7767                     thread_no_node_processor_spread | unbound
7768
7769          Warning:
7770              This argument is deprecated. Instead of using this argument, use
7771              command-line argument +sbt in  erl(1).  When  this  argument  is
7772              removed,  a  final  scheduler  bind type to use is determined at
7773              emulator boot time.
7774
7775
7776              Controls if and how schedulers are bound to logical processors.
7777
7778              When erlang:system_flag(scheduler_bind_type, How) is called,  an
7779              asynchronous  signal  is  sent to all schedulers online, causing
7780              them to try to bind or unbind as requested.
7781
7782          Note:
7783              If a scheduler fails to bind, this is often silently ignored, as
7784              it  is  not  always  possible  to verify valid logical processor
7785              identifiers. If an error is reported, an error event is  logged.
7786              To  verify  that  the  schedulers  have bound as requested, call
7787              erlang:system_info(scheduler_bindings).
7788
7789
7790              Schedulers can be bound on newer Linux,  Solaris,  FreeBSD,  and
7791              Windows  systems,  but  more systems will be supported in future
7792              releases.
7793
7794              In order for the runtime system to be able to  bind  schedulers,
7795              the  CPU  topology must be known. If the runtime system fails to
7796              detect the CPU topology automatically, it can  be  defined.  For
7797              more information on how to define the CPU topology, see command-
7798              line flag +sct in erl(1).
7799
7800              The runtime system does by default not bind schedulers to  logi‐
7801              cal processors.
7802
7803          Note:
7804              If  the  Erlang  runtime  system  is the only OS process binding
7805              threads to logical processors, this improves the performance  of
7806              the runtime system. However, if other OS processes (for example,
7807              another Erlang runtime system) also bind threads to logical pro‐
7808              cessors,  there  can be a performance penalty instead. Sometimes
7809              this performance penalty can be severe. If so, it is recommended
7810              to not bind the schedulers.
7811
7812
7813              Schedulers  can  be bound in different ways. Argument How deter‐
7814              mines how schedulers are bound and can be any of the following:
7815
7816                unbound:
7817                  Same as command-line argument +sbt u in erl(1).
7818
7819                no_spread:
7820                  Same as command-line argument +sbt ns in erl(1).
7821
7822                thread_spread:
7823                  Same as command-line argument +sbt ts in erl(1).
7824
7825                processor_spread:
7826                  Same as command-line argument +sbt ps in erl(1).
7827
7828                spread:
7829                  Same as command-line argument +sbt s in erl(1).
7830
7831                no_node_thread_spread:
7832                  Same as command-line argument +sbt nnts in erl(1).
7833
7834                no_node_processor_spread:
7835                  Same as command-line argument +sbt nnps in erl(1).
7836
7837                thread_no_node_processor_spread:
7838                  Same as command-line argument +sbt tnnps in erl(1).
7839
7840                default_bind:
7841                  Same as command-line argument +sbt db in erl(1).
7842
7843              The returned value equals How  before  flag  scheduler_bind_type
7844              was changed.
7845
7846              Failures:
7847
7848                notsup:
7849                  If binding of schedulers is not supported.
7850
7851                badarg:
7852                  If How is not one of the documented alternatives.
7853
7854                badarg:
7855                  If CPU topology information is unavailable.
7856
7857              The  scheduler bind type can also be set by passing command-line
7858              argument +sbt to erl(1).
7859
7860              For    more    information,    see     erlang:system_info(sched‐
7861              uler_bind_type), erlang:system_info(scheduler_bindings), as well
7862              as command-line flags +sbt and +sct in erl(1).
7863
7864       erlang:system_flag(Flag :: scheduler_wall_time, Boolean) ->
7865                             OldBoolean
7866
7867              Types:
7868
7869                 Boolean = OldBoolean = boolean()
7870
7871              Turns on or off scheduler wall time measurements.
7872
7873              For more information, see statistics(scheduler_wall_time).
7874
7875       erlang:system_flag(Flag :: schedulers_online, SchedulersOnline) ->
7876                             OldSchedulersOnline
7877
7878              Types:
7879
7880                 SchedulersOnline = OldSchedulersOnline = integer() >= 1
7881
7882              Sets the number of schedulers online. Range is 1  <=  Scheduler‐
7883              sOnline <= erlang:system_info(schedulers).
7884
7885              Returns the old value of the flag.
7886
7887              If  the  emulator  was built with support for  dirty schedulers,
7888              changing the number of schedulers online  can  also  change  the
7889              number of dirty CPU schedulers online. For example, if 12 sched‐
7890              ulers and 6 dirty CPU schedulers are online,  and  system_flag/2
7891              is  used  to  set the number of schedulers online to 6, then the
7892              number of dirty CPU schedulers online is automatically decreased
7893              by  half  as well, down to 3. Similarly, the number of dirty CPU
7894              schedulers online increases proportionally to increases  in  the
7895              number of schedulers online.
7896
7897              For  more  information,  see  erlang:system_info(schedulers) and
7898              erlang:system_info(schedulers_online).
7899
7900       erlang:system_flag(Flag :: system_logger, Logger) -> PrevLogger
7901
7902              Types:
7903
7904                 Logger = PrevLogger = logger | undefined | pid()
7905
7906              Sets the process that will receive the logging  messages  gener‐
7907              ated  by  ERTS. If set to undefined, all logging messages gener‐
7908              ated by ERTS will be dropped. The messages will be in  the  for‐
7909              mat:
7910
7911              {log,Level,Format,ArgList,Metadata} where
7912
7913              Level = atom(),
7914              Format = string(),
7915              ArgList = list(term()),
7916              Metadata = #{ pid => pid(),
7917                 group_leader => pid(),
7918                 time := logger:timestamp(),
7919                 error_logger := #{ emulator := true, tag := atom() }
7920
7921
7922              If  the  system_logger  process dies, this flag will be reset to
7923              logger.
7924
7925              The default is the process named logger.
7926
7927              Returns the old value of the flag.
7928
7929          Note:
7930              This function is designed to be used by the  KERNEL  logger.  Be
7931              careful  if  you change it to something else as log messages may
7932              be lost. If you want to intercept emulator log messages,  do  it
7933              by adding a specialized handler to the KERNEL logger.
7934
7935
7936       erlang:system_flag(Flag :: trace_control_word, TCW) -> OldTCW
7937
7938              Types:
7939
7940                 TCW = OldTCW = integer() >= 0
7941
7942              Sets  the  value of the node trace control word to TCW, which is
7943              to be an unsigned integer. For more  information,  see  function
7944              set_tcw  in  section  "Match  Specifications  in  Erlang" in the
7945              User's Guide.
7946
7947              Returns the old value of the flag.
7948
7949       erlang:system_flag(Flag :: time_offset, Value :: finalize) ->
7950                             OldState
7951
7952              Types:
7953
7954                 OldState = preliminary | final | volatile
7955
7956              Finalizes the time offset when single time warp mode is used. If
7957              another  time  warp  mode is used, the time offset state is left
7958              unchanged.
7959
7960              Returns the old state identifier, that is:
7961
7962                * If preliminary is returned, finalization was  performed  and
7963                  the time offset is now final.
7964
7965                * If  final  is  returned,  the time offset was already in the
7966                  final  state.  This  either  because   another   erlang:sys‐
7967                  tem_flag(time_offset, finalize) call or because no time warp
7968                  mode is used.
7969
7970                * If volatile is returned, the time offset cannot be finalized
7971                  because multi-time warp mode is used.
7972
7973       erlang:system_info(Item :: overview) -> boolean()
7974
7975              Returns  information about the current system. The documentation
7976              of this function is broken into the following sections in  order
7977              to make it easier to navigate.
7978
7979                Memory Allocation:
7980                  allocated_areas,  allocator,  alloc_util_allocators, alloca‐
7981                  tor_sizes, elib_malloc
7982
7983                CPU Topology:
7984                  cpu_topology, logical_processors, update_cpu_info
7985
7986                Process Information:
7987                  fullsweep_after, garbage_collection, heap_sizes,  heap_type,
7988                  max_heap_size,       message_queue_data,      min_heap_size,
7989                  min_bin_vheap_size, procs
7990
7991                System Limits:
7992                  atom_count, atom_limit,  ets_count,  ets_limit,  port_count,
7993                  port_limit, process_count, process_limit
7994
7995                System Time:
7996                  end_time,  os_monotonic_time_source,  os_system_time_source,
7997                  start_time,  time_correction,  time_offset,  time_warp_mode,
7998                  tolerant_timeofday
7999
8000                Scheduler Information:
8001                  dirty_cpu_schedulers,           dirty_cpu_schedulers_online,
8002                  dirty_io_schedulers,    multi_scheduling,     multi_schedul‐
8003                  ing_blockers,    normal_multi_scheduling_blockers,    sched‐
8004                  uler_bind_type,  scheduler_bindings,  scheduler_id,   sched‐
8005                  ulers, smp_support, threads, thread_pool_size
8006
8007                Distribution Information:
8008                  creation,  delayed_node_table_gc, dist, dist_buf_busy_limit,
8009                  dist_ctrl
8010
8011                System Information:
8012                  build_type,    c_compiler_used,    check_io,     compat_rel,
8013                  debug_compiled,        driver_version,        dynamic_trace,
8014                  dynamic_trace_probes, info,  kernel_poll,  loaded,  machine,
8015                  modified_timing_level, nif_version, otp_release, port_paral‐
8016                  lelism, system_architecture, system_logger,  system_version,
8017                  trace_control_word, version, wordsize
8018
8019       erlang:system_info(Item :: allocated_areas) -> [tuple()]
8020
8021       erlang:system_info(Item :: allocator) ->
8022                             {Allocator, Version, Features, Settings}
8023
8024       erlang:system_info(Item :: {allocator, Alloc}) -> [term()]
8025
8026       erlang:system_info(Item :: alloc_util_allocators) -> [Alloc]
8027
8028       erlang:system_info(Item :: {allocator_sizes, Alloc}) -> [term()]
8029
8030       erlang:system_info(Item :: elib_malloc) -> false
8031
8032              Types:
8033
8034                 Allocator = undefined | glibc
8035                 Version = [integer() >= 0]
8036                 Features = [atom()]
8037                 Settings =
8038                     [{Subsystem :: atom(),
8039                       [{Parameter :: atom(), Value :: term()}]}]
8040                 Alloc = atom()
8041
8042              Returns  various  information about the memory allocators of the
8043              current system (emulator) as specified by Item:
8044
8045                allocated_areas:
8046                  Returns a list of tuples with  information  about  miscella‐
8047                  neous allocated memory areas.
8048
8049                  Each tuple contains an atom describing the type of memory as
8050                  first element and the amount of allocated memory in bytes as
8051                  second  element.  When  information about allocated and used
8052                  memory is present, also a third element is present, contain‐
8053                  ing the amount of used memory in bytes.
8054
8055                  erlang:system_info(allocated_areas)  is  intended for debug‐
8056                  ging, and the content  is  highly  implementation-dependent.
8057                  The  content  of  the  results therefore changes when needed
8058                  without prior notice.
8059
8060                  Notice that the sum of these values is not the total  amount
8061                  of memory allocated by the emulator. Some values are part of
8062                  other values, and some memory areas  are  not  part  of  the
8063                  result.  For  information  about  the total amount of memory
8064                  allocated by the emulator, see erlang:memory/0,1.
8065
8066                allocator:
8067                  Returns {Allocator, Version, Features, Settings, where:
8068
8069                  * Allocator corresponds to the malloc() implementation used.
8070                    If Allocator equals undefined, the malloc() implementation
8071                    used cannot be identified. glibc can be identified.
8072
8073                  * Version is a list of integers (but not  a  string)  repre‐
8074                    senting the version of the malloc() implementation used.
8075
8076                  * Features  is  a  list of atoms representing the allocation
8077                    features used.
8078
8079                  * Settings is  a  list  of  subsystems,  their  configurable
8080                    parameters,  and  used values. Settings can differ between
8081                    different combinations of platforms, allocators, and allo‐
8082                    cation features. Memory sizes are given in bytes.
8083
8084                  See    also   "System   Flags   Effecting   erts_alloc"   in
8085                  erts_alloc(3).
8086
8087                {allocator, Alloc}:
8088                  Returns information about the specified allocator.  As  from
8089                  ERTS 5.6.1, the return value is a list of {instance, Instan‐
8090                  ceNo,  InstanceInfo}  tuples,  where  InstanceInfo  contains
8091                  information  about  a specific instance of the allocator. If
8092                  Alloc is not a recognized allocator, undefined is  returned.
8093                  If Alloc is disabled, false is returned.
8094
8095                  Notice  that  the information returned is highly implementa‐
8096                  tion-dependent and can be changed or  removed  at  any  time
8097                  without  prior  notice.  It was initially intended as a tool
8098                  when developing new allocators, but as it can be of interest
8099                  for others it has been briefly documented.
8100
8101                  The  recognized  allocators  are  listed  in  erts_alloc(3).
8102                  Information about super carriers can be obtained  from  ERTS
8103                  8.0  with  {allocator,  erts_mmap}  or from ERTS 5.10.4; the
8104                  returned list when calling with {allocator, mseg_alloc} also
8105                  includes an {erts_mmap, _} tuple as one element in the list.
8106
8107                  After  reading the erts_alloc(3) documentation, the returned
8108                  information more or less speaks for itself, but  it  can  be
8109                  worth  explaining  some things. Call counts are presented by
8110                  two values, the first value is giga calls,  and  the  second
8111                  value  is  calls. mbcs and sbcs denote multi-block carriers,
8112                  and single-block carriers, respectively. Sizes are presented
8113                  in  bytes. When a size is not presented, it is the amount of
8114                  something. Sizes and amounts are often  presented  by  three
8115                  values:
8116
8117                  * The first is the current value.
8118
8119                  * The  second  is  the  maximum value since the last call to
8120                    erlang:system_info({allocator, Alloc}).
8121
8122                  * The third is the maximum  value  since  the  emulator  was
8123                    started.
8124
8125                  If  only  one  value  is  present,  it is the current value.
8126                  fix_alloc memory block types are presented  by  two  values.
8127                  The first value is the memory pool size and the second value
8128                  is the used memory size.
8129
8130                alloc_util_allocators:
8131                  Returns a list of the names of all allocators using the ERTS
8132                  internal  alloc_util  framework  as atoms. For more informa‐
8133                  tion, see section The alloc_util framework in erts_alloc(3).
8134
8135                {allocator_sizes, Alloc}:
8136                  Returns various size information for the  specified  alloca‐
8137                  tor. The information returned is a subset of the information
8138                  returned by erlang:system_info({allocator, Alloc}).
8139
8140                elib_malloc:
8141                  This option will be removed in a future release. The  return
8142                  value will always be false, as the elib_malloc allocator has
8143                  been removed.
8144
8145       erlang:system_info(Item :: cpu_topology) -> CpuTopology
8146
8147       erlang:system_info(Item ::
8148                              {cpu_topology, defined | detected | used}) ->
8149                             CpuTopology
8150
8151       erlang:system_info(Item ::
8152                              logical_processors |
8153                              logical_processors_available |
8154                              logical_processors_online) ->
8155                             unknown | integer() >= 1
8156
8157       erlang:system_info(Item :: update_cpu_info) -> changed | unchanged
8158
8159              Types:
8160
8161                 cpu_topology() = [LevelEntry :: level_entry()] | undefined
8162                    All LevelEntrys of a list must contain the same  LevelTag,
8163                   except  on  the  top  level  where both node and processor‐
8164                   LevelTags can coexist.
8165                 level_entry() =
8166                     {LevelTag :: level_tag(), SubLevel :: sub_level()} |
8167                     {LevelTag :: level_tag(),
8168                      InfoList :: info_list(),
8169                      SubLevel :: sub_level()}
8170                   {LevelTag, SubLevel} == {LevelTag, [], SubLevel}
8171                 level_tag() = core | node | processor | thread
8172                    More LevelTags can be introduced in a future release.
8173                 sub_level() =
8174                     [LevelEntry :: level_entry()] |
8175                     (LogicalCpuId :: {logical, integer() >= 0})
8176                 info_list() = []
8177                    The info_list() can be extended in a future release.
8178
8179              Returns various information about the CPU topology of  the  cur‐
8180              rent system (emulator) as specified by Item:
8181
8182                cpu_topology:
8183                  Returns  the CpuTopology currently used by the emulator. The
8184                  CPU topology is used when binding schedulers to logical pro‐
8185                  cessors.  The  CPU  topology  used  is the  user-defined CPU
8186                  topology,  if  such  exists,  otherwise  the   automatically
8187                  detected  CPU  topology,  if such exists. If no CPU topology
8188                  exists, undefined is returned.
8189
8190                  node refers  to  Non-Uniform  Memory  Access  (NUMA)  nodes.
8191                  thread refers to hardware threads (for example, Intel hyper-
8192                  threads).
8193
8194                  A level in term CpuTopology can be omitted if only one entry
8195                  exists and InfoList is empty.
8196
8197                  thread  can  only  be a sublevel to core. core can be a sub‐
8198                  level to processor or node. processor  can  be  on  the  top
8199                  level or a sublevel to node. node can be on the top level or
8200                  a sublevel to processor. That is, NUMA nodes can be  proces‐
8201                  sor  internal or processor external. A CPU topology can con‐
8202                  sist of a mix of processor internal and external NUMA nodes,
8203                  as  long as each logical CPU belongs to one NUMA node. Cache
8204                  hierarchy is not part of the CpuTopology type, but  will  be
8205                  in  a future release. Other things can also make it into the
8206                  CPU topology in a future release. So, expect the CpuTopology
8207                  type to change.
8208
8209                {cpu_topology, defined}:
8210
8211
8212                  Returns  the user-defined CpuTopology. For more information,
8213                  see command-line flag +sct in erl(1) and argument cpu_topol‐
8214                  ogy.
8215
8216                {cpu_topology, detected}:
8217
8218
8219                  Returns  the automatically detected CpuTopologyy. The emula‐
8220                  tor detects the CPU topology on some newer  Linux,  Solaris,
8221                  FreeBSD,  and  Windows  systems. On Windows system with more
8222                  than  32  logical  processors,  the  CPU  topology  is   not
8223                  detected.
8224
8225                  For more information, see argument cpu_topology.
8226
8227                {cpu_topology, used}:
8228                  Returns  CpuTopology used by the emulator. For more informa‐
8229                  tion, see argument cpu_topology.
8230
8231                logical_processors:
8232                  Returns the detected number of logical processors configured
8233                  in the system. The return value is either an integer, or the
8234                  atom unknown if the emulator cannot  detect  the  configured
8235                  logical processors.
8236
8237                logical_processors_available:
8238                  Returns  the detected number of logical processors available
8239                  to the Erlang runtime system. The return value is either  an
8240                  integer,  or  the atom unknown if the emulator cannot detect
8241                  the available logical processors. The  number  of  available
8242                  logical  processors  is  less than or equal to the number of
8243                  logical processors online.
8244
8245                logical_processors_online:
8246                  Returns the detected number of logical processors online  on
8247                  the  system.  The  return value is either an integer, or the
8248                  atom unknown if the emulator cannot detect  logical  proces‐
8249                  sors online. The number of logical processors online is less
8250                  than or equal to the number of  logical  processors  config‐
8251                  ured.
8252
8253                cpu_quota:
8254                  Returns  the  detected CPU quota the emulator is limited by.
8255                  The return value is an integer saying how  many  processors'
8256                  worth of runtime we get (between 1 and the number of logical
8257                  processors), or the atom  unknown  if  the  emulator  cannot
8258                  detect a quota.
8259
8260                update_cpu_info:
8261                  The runtime system rereads the CPU information available and
8262                  updates its internally stored information about the detected
8263                  CPU  topology  and  the number of logical processors config‐
8264                  ured, online, available, and cpu quota.
8265
8266                  If the CPU information has changed since the  last  time  it
8267                  was  read,  the atom changed is returned, otherwise the atom
8268                  unchanged. If the CPU information has changed, you  probably
8269                  want  to  adjust  the number of schedulers online. You typi‐
8270                  cally want to have as many schedulers online as logical pro‐
8271                  cessors available.
8272
8273       erlang:system_info(Item :: fullsweep_after) ->
8274                             {fullsweep_after, integer() >= 0}
8275
8276       erlang:system_info(Item :: garbage_collection) ->
8277                             [{atom(), integer()}]
8278
8279       erlang:system_info(Item :: heap_sizes) -> [integer() >= 0]
8280
8281       erlang:system_info(Item :: heap_type) -> private
8282
8283       erlang:system_info(Item :: max_heap_size) ->
8284                             {max_heap_size,
8285                              MaxHeapSize :: max_heap_size()}
8286
8287       erlang:system_info(Item :: message_queue_data) ->
8288                             message_queue_data()
8289
8290       erlang:system_info(Item :: min_heap_size) ->
8291                             {min_heap_size,
8292                              MinHeapSize :: integer() >= 1}
8293
8294       erlang:system_info(Item :: min_bin_vheap_size) ->
8295                             {min_bin_vheap_size,
8296                              MinBinVHeapSize :: integer() >= 1}
8297
8298       erlang:system_info(Item :: procs) -> binary()
8299
8300              Types:
8301
8302                 message_queue_data() = off_heap | on_heap
8303                 max_heap_size() =
8304                     integer() >= 0 |
8305                     #{size => integer() >= 0,
8306                       kill => boolean(),
8307                       error_logger => boolean()}
8308
8309              Returns information about the default process heap settings:
8310
8311                fullsweep_after:
8312                  Returns  {fullsweep_after,  integer()  >=  0},  which is the
8313                  fullsweep_after garbage collection setting used by  default.
8314                  For   more  information,  see  garbage_collection  described
8315                  below.
8316
8317                garbage_collection:
8318                  Returns a list describing  the  default  garbage  collection
8319                  settings.  A process spawned on the local node by a spawn or
8320                  spawn_link  uses  these  garbage  collection  settings.  The
8321                  default   settings  can  be  changed  by  using  erlang:sys‐
8322                  tem_flag/2. spawn_opt/2,3,4 can spawn a  process  that  does
8323                  not use the default settings.
8324
8325                heap_sizes:
8326                  Returns  a list of integers representing valid heap sizes in
8327                  words. All Erlang heaps are sized from sizes in this list.
8328
8329                heap_type:
8330                  Returns the heap type used by the current emulator. One heap
8331                  type exists:
8332
8333                  private:
8334                     Each  process has a heap reserved for its use and no ref‐
8335                    erences between heaps of different processes are  allowed.
8336                    Messages  passed  between  processes  are  copied  between
8337                    heaps.
8338
8339                max_heap_size:
8340                  Returns {max_heap_size, MaxHeapSize}, where  MaxHeapSize  is
8341                  the  current  system-wide  maximum  heap  size  settings for
8342                  spawned processes. This setting can be set  using  the  com‐
8343                  mand-line  flags +hmax, +hmaxk and +hmaxel in erl(1). It can
8344                  also   be   changed    at    runtime    using    erlang:sys‐
8345                  tem_flag(max_heap_size, MaxHeapSize). For more details about
8346                  the       max_heap_size       process       flag,        see
8347                  process_flag(max_heap_size, MaxHeapSize).
8348
8349                message_queue_data:
8350                  Returns  the default value of the message_queue_data process
8351                  flag, which can be either off_heap or on_heap.  The  default
8352                  value  is  set by the command-line argument +hmqd in erl(1).
8353                  For   more   information,   see   the    documentation    of
8354                  process_flag(message_queue_data, MQD).
8355
8356                min_heap_size:
8357                  Returns  {min_heap_size,  MinHeapSize}, where MinHeapSize is
8358                  the current system-wide minimum heap size for  spawned  pro‐
8359                  cesses.
8360
8361                min_bin_vheap_size:
8362                  Returns {min_bin_vheap_size, MinBinVHeapSize}, where MinBin‐
8363                  VHeapSize is the current system-wide minimum binary  virtual
8364                  heap size for spawned processes.
8365
8366                procs:
8367                  Returns  a  binary  containing  a string of process and port
8368                  information formatted as in Erlang  crash  dumps.  For  more
8369                  information,  see section  How to interpret the Erlang crash
8370                  dumps in the User's Guide.
8371
8372       erlang:system_info(Item :: atom_count) -> integer() >= 1
8373
8374       erlang:system_info(Item :: atom_limit) -> integer() >= 1
8375
8376       erlang:system_info(Item :: ets_count) -> integer() >= 1
8377
8378       erlang:system_info(Item :: ets_limit) -> integer() >= 1
8379
8380       erlang:system_info(Item :: port_count) -> integer() >= 0
8381
8382       erlang:system_info(Item :: port_limit) -> integer() >= 1
8383
8384       erlang:system_info(Item :: process_count) -> integer() >= 1
8385
8386       erlang:system_info(Item :: process_limit) -> integer() >= 1
8387
8388              Returns information about the current system  (emulator)  limits
8389              as specified by Item:
8390
8391                atom_count:
8392                  Returns  the number of atoms currently existing at the local
8393                  node. The value is given as an integer.
8394
8395                atom_limit:
8396                  Returns the maximum number of atoms allowed. This limit  can
8397                  be  increased  at startup by passing command-line flag +t to
8398                  erl(1).
8399
8400                ets_count:
8401                  Returns the number of ETS tables currently existing  at  the
8402                  local node.
8403
8404                ets_limit:
8405                  Returns  the  limit  for number of ETS tables. This limit is
8406                  partially obsolete and number of tables are only limited  by
8407                  available memory.
8408
8409                port_count:
8410                  Returns  the number of ports currently existing at the local
8411                  node. The value is given as an integer.  This  is  the  same
8412                  value  as returned by length(erlang:ports()), but more effi‐
8413                  cient.
8414
8415                port_limit:
8416                  Returns the maximum number of simultaneously existing  ports
8417                  at  the  local node as an integer. This limit can be config‐
8418                  ured at startup by using command-line flag +Q in erl(1).
8419
8420                process_count:
8421                  Returns the number of processes currently  existing  at  the
8422                  local  node.  The  value is given as an integer. This is the
8423                  same value as  returned  by  length(processes()),  but  more
8424                  efficient.
8425
8426                process_limit:
8427                  Returns  the  maximum number of simultaneously existing pro‐
8428                  cesses at the local node. The value is given as an  integer.
8429                  This  limit  can  be configured at startup by using command-
8430                  line flag +P in erl(1).
8431
8432       erlang:system_info(Item :: end_time) -> integer() >= 0
8433
8434       erlang:system_info(Item :: os_monotonic_time_source) ->
8435                             [{atom(), term()}]
8436
8437       erlang:system_info(Item :: os_system_time_source) ->
8438                             [{atom(), term()}]
8439
8440       erlang:system_info(Item :: start_time) -> integer()
8441
8442       erlang:system_info(Item :: time_correction) -> true | false
8443
8444       erlang:system_info(Item :: time_offset) ->
8445                             preliminary | final | volatile
8446
8447       erlang:system_info(Item :: time_warp_mode) ->
8448                             no_time_warp | single_time_warp |
8449                             multi_time_warp
8450
8451       erlang:system_info(Item :: tolerant_timeofday) ->
8452                             enabled | disabled
8453
8454              Returns information about the current system (emulator) time  as
8455              specified by Item:
8456
8457                end_time:
8458                  The  last Erlang monotonic time in native time unit that can
8459                  be represented internally in the current Erlang runtime sys‐
8460                  tem  instance.  The  time between the start time and the end
8461                  time is at least a quarter of a millennium.
8462
8463                os_monotonic_time_source:
8464                  Returns a list containing information about the source of OS
8465                  monotonic time that is used by the runtime system.
8466
8467                  If  []  is  returned, no OS monotonic time is available. The
8468                  list contains two-tuples with Keys  as  first  element,  and
8469                  Values as second element. The order of these tuples is unde‐
8470                  fined. The following tuples can be part  of  the  list,  but
8471                  more tuples can be introduced in the future:
8472
8473                  {function, Function}:
8474                    Function  is  the  name  of  the function used. This tuple
8475                    always exists if OS monotonic time  is  available  to  the
8476                    runtime system.
8477
8478                  {clock_id, ClockId}:
8479                    This  tuple  only exists if Function can be used with dif‐
8480                    ferent clocks. ClockId corresponds to the clock identifier
8481                    used when calling Function.
8482
8483                  {resolution, OsMonotonicTimeResolution}:
8484                    Highest  possible  resolution of current OS monotonic time
8485                    source as parts per second. If no  resolution  information
8486                    can be retrieved from the OS, OsMonotonicTimeResolution is
8487                    set to the resolution of the time unit of Functions return
8488                    value.  That  is,  the actual resolution can be lower than
8489                    OsMonotonicTimeResolution. Notice that the resolution does
8490                    not  say anything about the  accuracy or whether the  pre‐
8491                    cision aligns with the resolution. You do,  however,  know
8492                    that the precision is not better than OsMonotonicTimeReso‐
8493                    lution.
8494
8495                  {extended, Extended}:
8496                    Extended equals yes if the range of time values  has  been
8497                    extended;  otherwise Extended equals no. The range must be
8498                    extended if Function returns values that wrap  fast.  This
8499                    typically  is  the  case when the return value is a 32-bit
8500                    value.
8501
8502                  {parallel, Parallel}:
8503                    Parallel equals yes if Function is called in parallel from
8504                    multiple threads. If it is not called in parallel, because
8505                    calls must be serialized, Parallel equals no.
8506
8507                  {time, OsMonotonicTime}:
8508                    OsMonotonicTime equals current OS monotonic time in native
8509                    time unit.
8510
8511                os_system_time_source:
8512                  Returns a list containing information about the source of OS
8513                  system time that is used by the runtime system.
8514
8515                  The list contains two-tuples with Keys as first element, and
8516                  Values as second element. The order of these tuples is unde‐
8517                  fined. The following tuples can be part  of  the  list,  but
8518                  more tuples can be introduced in the future:
8519
8520                  {function, Function}:
8521                    Function is the name of the funcion used.
8522
8523                  {clock_id, ClockId}:
8524                    Exists only if Function can be used with different clocks.
8525                    ClockId corresponds to  the  clock  identifier  used  when
8526                    calling Function.
8527
8528                  {resolution, OsSystemTimeResolution}:
8529                    Highest  possible   resolution  of  current OS system time
8530                    source as parts per second. If no  resolution  information
8531                    can  be  retrieved  from the OS, OsSystemTimeResolution is
8532                    set to the resolution of the time unit of Functions return
8533                    value.  That  is,  the actual resolution can be lower than
8534                    OsSystemTimeResolution. Notice that  the  resolution  does
8535                    not  say anything about the  accuracy or whether the  pre‐
8536                    cision do align with the resolution. You do, however, know
8537                    that  the precision is not better than OsSystemTimeResolu‐
8538                    tion.
8539
8540                  {parallel, Parallel}:
8541                    Parallel equals yes if Function is called in parallel from
8542                    multiple threads. If it is not called in parallel, because
8543                    calls needs to be serialized, Parallel equals no.
8544
8545                  {time, OsSystemTime}:
8546                    OsSystemTime equals current OS system time in native  time
8547                    unit.
8548
8549                start_time:
8550                  The  Erlang  monotonic  time in native time unit at the time
8551                  when current Erlang runtime system instance started.
8552
8553                  See also erlang:system_info(end_time).
8554
8555                time_correction:
8556                  Returns a boolean value indicating whether  time  correction
8557                  is enabled or not.
8558
8559                time_offset:
8560                  Returns the state of the time offset:
8561
8562                  preliminary:
8563                    The  time  offset  is preliminary, and will be changed and
8564                    finalized later. The preliminary time offset is used  dur‐
8565                    ing the preliminary phase of the  single time warp mode.
8566
8567                  final:
8568                    The  time  offset  is  final. This either because  no time
8569                    warp mode is used, or because the time  offset  have  been
8570                    finalized when  single time warp mode is used.
8571
8572                  volatile:
8573                    The time offset is volatile. That is, it can change at any
8574                    time. This is because  multi-time warp mode is used.
8575
8576                time_warp_mode:
8577                  Returns a value identifying the   time  warp  mode  that  is
8578                  used:
8579
8580                  no_time_warp:
8581                    The  no time warp mode is used.
8582
8583                  single_time_warp:
8584                    The  single time warp mode is used.
8585
8586                  multi_time_warp:
8587                    The  multi-time warp mode is used.
8588
8589                tolerant_timeofday:
8590                  Returns  whether a pre ERTS 7.0 backwards compatible compen‐
8591                  sation for sudden changes of system time is enabled or  dis‐
8592                  abled.  Such compensation is enabled when the time offset is
8593                  final, and  time correction is enabled.
8594
8595       erlang:system_info(Item :: dirty_cpu_schedulers) ->
8596                             integer() >= 0
8597
8598       erlang:system_info(Item :: dirty_cpu_schedulers_online) ->
8599                             integer() >= 0
8600
8601       erlang:system_info(Item :: dirty_io_schedulers) ->
8602                             integer() >= 0
8603
8604       erlang:system_info(Item :: multi_scheduling) ->
8605                             disabled | blocked | blocked_normal |
8606                             enabled
8607
8608       erlang:system_info(Item :: multi_scheduling_blockers) ->
8609                             [Pid :: pid()]
8610
8611       erlang:system_info(Item :: otp_release) -> string()
8612
8613       erlang:system_info(Item :: scheduler_bind_type) ->
8614                             spread | processor_spread | thread_spread |
8615                             thread_no_node_processor_spread |
8616                             no_node_processor_spread |
8617                             no_node_thread_spread | no_spread | unbound
8618
8619       erlang:system_info(Item :: scheduler_bindings) -> tuple()
8620
8621       erlang:system_info(Item :: scheduler_id) ->
8622                             SchedulerId :: integer() >= 1
8623
8624       erlang:system_info(Item :: schedulers | schedulers_online) ->
8625                             integer() >= 1
8626
8627       erlang:system_info(Item :: smp_support) -> boolean()
8628
8629       erlang:system_info(Item :: threads) -> boolean()
8630
8631       erlang:system_info(Item :: thread_pool_size) -> integer() >= 0
8632
8633              Returns information about schedulers, scheduling and threads  in
8634              the current system as specified by Item:
8635
8636                dirty_cpu_schedulers:
8637                  Returns  the  number  of dirty CPU scheduler threads used by
8638                  the emulator. Dirty CPU schedulers execute CPU-bound  native
8639                  functions,  such  as  NIFs,  linked-in driver code, and BIFs
8640                  that cannot be managed cleanly by the normal emulator sched‐
8641                  ulers.
8642
8643                  The  number  of dirty CPU scheduler threads is determined at
8644                  emulator boot time and cannot be changed  after  that.  How‐
8645                  ever,  the  number of dirty CPU scheduler threads online can
8646                  be changed at any time. The number of dirty  CPU  schedulers
8647                  can be set at startup by passing command-line flag +SDcpu or
8648                  +SDPcpu in erl(1).
8649
8650                  See   also   erlang:system_flag(dirty_cpu_schedulers_online,
8651                  DirtyCPUSchedulersOnline),                       erlang:sys‐
8652                  tem_info(dirty_cpu_schedulers_online),           erlang:sys‐
8653                  tem_info(dirty_io_schedulers),     erlang:system_info(sched‐
8654                  ulers),      erlang:system_info(schedulers_online),      and
8655                  erlang:system_flag(schedulers_online, SchedulersOnline).
8656
8657                dirty_cpu_schedulers_online:
8658                  Returns  the  number  of  dirty  CPU  schedulers online. The
8659                  return value satisfies 1 <= DirtyCPUSchedulersOnline  <=  N,
8660                  where  N is the smallest of the return values of erlang:sys‐
8661                  tem_info(dirty_cpu_schedulers) and erlang:system_info(sched‐
8662                  ulers_online).
8663
8664                  The  number  of  dirty  CPU  schedulers online can be set at
8665                  startup by passing command-line flag +SDcpu in erl(1).
8666
8667                  For      more       information,       see       erlang:sys‐
8668                  tem_info(dirty_cpu_schedulers),                  erlang:sys‐
8669                  tem_info(dirty_io_schedulers),     erlang:system_info(sched‐
8670                  ulers_online),    and    erlang:system_flag(dirty_cpu_sched‐
8671                  ulers_online, DirtyCPUSchedulersOnline).
8672
8673                dirty_io_schedulers:
8674                  Returns the number of dirty I/O schedulers  as  an  integer.
8675                  Dirty  I/O  schedulers  execute  I/O-bound native functions,
8676                  such as NIFs and linked-in driver code, which cannot be man‐
8677                  aged cleanly by the normal emulator schedulers.
8678
8679                  This  value  can  be  set at startup by passing command-line
8680                  argument +SDio in erl(1).
8681
8682                  For      more       information,       see       erlang:sys‐
8683                  tem_info(dirty_cpu_schedulers),                  erlang:sys‐
8684                  tem_info(dirty_cpu_schedulers_online),    and    erlang:sys‐
8685                  tem_flag(dirty_cpu_schedulers_online,  DirtyCPUSchedulersOn‐
8686                  line).
8687
8688                multi_scheduling:
8689                  Returns one of the following:
8690
8691                  disabled:
8692                    The emulator has been  started  with  only  one  scheduler
8693                    thread.
8694
8695                  blocked:
8696                    The  emulator  has more than one scheduler thread, but all
8697                    scheduler threads except one are blocked.  That  is,  only
8698                    one  scheduler  thread schedules Erlang processes and exe‐
8699                    cutes Erlang code.
8700
8701                  blocked_normal:
8702                    The emulator has more than one scheduler thread,  but  all
8703                    normal  scheduler  threads  except one are blocked. Notice
8704                    that dirty schedulers are not blocked,  and  can  schedule
8705                    Erlang processes and execute native code.
8706
8707                  enabled:
8708                    The  emulator  has  more than one scheduler thread, and no
8709                    scheduler threads are  blocked.  That  is,  all  available
8710                    scheduler  threads  schedule  Erlang processes and execute
8711                    Erlang code.
8712
8713                  See also  erlang:system_flag(multi_scheduling,  BlockState),
8714                  erlang:system_info(multi_scheduling_blockers),   erlang:sys‐
8715                  tem_info(normal_multi_scheduling_blockers), and  erlang:sys‐
8716                  tem_info(schedulers).
8717
8718                multi_scheduling_blockers:
8719                  Returns  a  list  of  Pids when multi-scheduling is blocked,
8720                  otherwise the empty list is returned. The Pids in  the  list
8721                  represent  all the processes currently blocking multi-sched‐
8722                  uling. A Pid occurs only once in the list, even if the  cor‐
8723                  responding process has blocked multiple times.
8724
8725                  See  also  erlang:system_flag(multi_scheduling, BlockState),
8726                  erlang:system_info(multi_scheduling),            erlang:sys‐
8727                  tem_info(normal_multi_scheduling_blockers),  and erlang:sys‐
8728                  tem_info(schedulers).
8729
8730                normal_multi_scheduling_blockers:
8731                  Returns a list  of  Pids  when  normal  multi-scheduling  is
8732                  blocked (that is, all normal schedulers but one is blocked),
8733                  otherwise the empty list is returned. The Pids in  the  list
8734                  represent all the processes currently blocking normal multi-
8735                  scheduling. A Pid occurs only once in the list, even if  the
8736                  corresponding process has blocked multiple times.
8737
8738                  See  also  erlang:system_flag(multi_scheduling, BlockState),
8739                  erlang:system_info(multi_scheduling),            erlang:sys‐
8740                  tem_info(multi_scheduling_blockers),     and     erlang:sys‐
8741                  tem_info(schedulers).
8742
8743                scheduler_bind_type:
8744                  Returns information about how the user has requested  sched‐
8745                  ulers to be bound or not bound.
8746
8747                  Notice  that  although a user has requested schedulers to be
8748                  bound, they can silently have failed to bind. To inspect the
8749                  scheduler  bindings, call erlang:system_info(scheduler_bind‐
8750                  ings).
8751
8752                  For more information,  see  command-line  argument  +sbt  in
8753                  erl(1) and erlang:system_info(scheduler_bindings).
8754
8755                scheduler_bindings:
8756                  Returns information about the currently used scheduler bind‐
8757                  ings.
8758
8759                  A tuple of a size equal to erlang:system_info(schedulers) is
8760                  returned.  The  tuple  elements  are  integers  or  the atom
8761                  unbound. Logical processor identifiers  are  represented  as
8762                  integers.  The  Nth  element of the tuple equals the current
8763                  binding for the  scheduler  with  the  scheduler  identifier
8764                  equal  to  N. For example, if the schedulers are bound, ele‐
8765                  ment(erlang:system_info(scheduler_id),           erlang:sys‐
8766                  tem_info(scheduler_bindings))  returns the identifier of the
8767                  logical processor that the calling process is executing on.
8768
8769                  Notice that only schedulers online can be bound  to  logical
8770                  processors.
8771
8772                  For  more  information,  see  command-line  argument +sbt in
8773                  erl(1) and erlang:system_info(schedulers_online).
8774
8775                scheduler_id:
8776                  Returns the scheduler  ID  (SchedulerId)  of  the  scheduler
8777                  thread that the calling process is executing on. SchedulerId
8778                  is a positive integer, where 1 <= SchedulerId <= erlang:sys‐
8779                  tem_info(schedulers).
8780
8781                  See also erlang:system_info(schedulers).
8782
8783                schedulers:
8784                  Returns  the  number of scheduler threads used by the emula‐
8785                  tor. Scheduler threads online schedules Erlang processes and
8786                  Erlang  ports,  and execute Erlang code and Erlang linked-in
8787                  driver code.
8788
8789                  The number of scheduler threads is  determined  at  emulator
8790                  boot  time  and cannot be changed later. However, the number
8791                  of schedulers online can be changed at any time.
8792
8793                  See also erlang:system_flag(schedulers_online, SchedulersOn‐
8794                  line),   erlang:system_info(schedulers_online),  erlang:sys‐
8795                  tem_info(scheduler_id), erlang:system_flag(multi_scheduling,
8796                  BlockState),           erlang:system_info(multi_scheduling),
8797                  erlang:system_info(normal_multi_scheduling_blockers)     and
8798                  erlang:system_info(multi_scheduling_blockers).
8799
8800                schedulers_online:
8801                  Returns the number of schedulers online. The scheduler iden‐
8802                  tifiers of schedulers online satisfy the relationship  1  <=
8803                  SchedulerId <= erlang:system_info(schedulers_online).
8804
8805                  For more information, see erlang:system_info(schedulers) and
8806                  erlang:system_flag(schedulers_online, SchedulersOnline).
8807
8808                smp_support:
8809                  Returns true.
8810
8811                threads:
8812                  Returns true.
8813
8814                thread_pool_size:
8815
8816
8817                  Returns the number of async threads in the async thread pool
8818                  used        for        asynchronous       driver       calls
8819                  (erl_driver:driver_async()). The value is given as an  inte‐
8820                  ger.
8821
8822       erlang:system_info(Item :: creation) -> integer()
8823
8824       erlang:system_info(Item :: delayed_node_table_gc) ->
8825                             infinity | integer() >= 0
8826
8827       erlang:system_info(Item :: dist) -> binary()
8828
8829       erlang:system_info(Item :: dist_buf_busy_limit) ->
8830                             integer() >= 0
8831
8832       erlang:system_info(Item :: dist_ctrl) ->
8833                             {Node :: node(),
8834                              ControllingEntity :: port() | pid()}
8835
8836              Returns  information  about  Erlang  Distribution in the current
8837              system as specified by Item:
8838
8839                creation:
8840                  Returns the creation of the local node as  an  integer.  The
8841                  creation  is  changed when a node is restarted. The creation
8842                  of a node is stored in  process  identifiers,  port  identi‐
8843                  fiers, and references. This makes it (to some extent) possi‐
8844                  ble to distinguish between identifiers from different incar‐
8845                  nations  of  a node. The valid creations are integers in the
8846                  range 1..3, but  this  will  probably  change  in  a  future
8847                  release. If the node is not alive, 0 is returned.
8848
8849                delayed_node_table_gc:
8850                  Returns  the amount of time in seconds garbage collection of
8851                  an entry in a node table is delayed. This limit can  be  set
8852                  on  startup  by passing command-line flag +zdntgc to erl(1).
8853                  For more information, see the documentation of the  command-
8854                  line flag.
8855
8856                dist:
8857                  Returns  a binary containing a string of distribution infor‐
8858                  mation formatted as in Erlang crash dumps. For more informa‐
8859                  tion,  see  section  How to interpret the Erlang crash dumps
8860                  in the User's Guide.
8861
8862                dist_buf_busy_limit:
8863                  Returns the value of the distribution buffer busy  limit  in
8864                  bytes.  This limit can be set at startup by passing command-
8865                  line flag +zdbbl to erl(1).
8866
8867                dist_ctrl:
8868                  Returns a list  of  tuples  {Node,  ControllingEntity},  one
8869                  entry  for each connected remote node. Node is the node name
8870                  and ControllingEntity is  the  port  or  process  identifier
8871                  responsible for the communication to that node. More specif‐
8872                  ically, ControllingEntity for nodes connected through TCP/IP
8873                  (the  normal  case) is the socket used in communication with
8874                  the specific node.
8875
8876       erlang:system_info(Item :: build_type) ->
8877                             opt | debug | purify | quantify | purecov |
8878                             gcov | valgrind | gprof | lcnt | frmptr
8879
8880       erlang:system_info(Item :: c_compiler_used) -> {atom(), term()}
8881
8882       erlang:system_info(Item :: check_io) -> [term()]
8883
8884       erlang:system_info(Item :: compat_rel) -> integer()
8885
8886       erlang:system_info(Item :: debug_compiled) -> boolean()
8887
8888       erlang:system_info(Item :: driver_version) -> string()
8889
8890       erlang:system_info(Item :: dynamic_trace) ->
8891                             none | dtrace | systemtap
8892
8893       erlang:system_info(Item :: dynamic_trace_probes) -> boolean()
8894
8895       erlang:system_info(Item :: info) -> binary()
8896
8897       erlang:system_info(Item :: kernel_poll) -> boolean()
8898
8899       erlang:system_info(Item :: loaded) -> binary()
8900
8901       erlang:system_info(Item :: machine) -> string()
8902
8903       erlang:system_info(Item :: modified_timing_level) ->
8904                             integer() | undefined
8905
8906       erlang:system_info(Item :: nif_version) -> string()
8907
8908       erlang:system_info(Item :: otp_release) -> string()
8909
8910       erlang:system_info(Item :: port_parallelism) -> boolean()
8911
8912       erlang:system_info(Item :: system_architecture) -> string()
8913
8914       erlang:system_info(Item :: system_logger) ->
8915                             logger | undefined | pid()
8916
8917       erlang:system_info(Item :: system_version) -> string()
8918
8919       erlang:system_info(Item :: trace_control_word) ->
8920                             integer() >= 0
8921
8922       erlang:system_info(Item :: version) -> string()
8923
8924       erlang:system_info(Item ::
8925                              wordsize |
8926                              {wordsize, internal} |
8927                              {wordsize, external}) ->
8928                             4 | 8
8929
8930              Returns various information about the current system  (emulator)
8931              as specified by Item:
8932
8933                build_type:
8934                  Returns  an  atom  describing  the build type of the runtime
8935                  system. This is normally the atom opt for  optimized.  Other
8936                  possible return values are debug, purify, quantify, purecov,
8937                  gcov, valgrind, gprof, and lcnt. Possible return values  can
8938                  be added or removed at any time without prior notice.
8939
8940                c_compiler_used:
8941                  Returns a two-tuple describing the C compiler used when com‐
8942                  piling the runtime system. The  first  element  is  an  atom
8943                  describing  the  name  of  the  compiler,  or  undefined  if
8944                  unknown. The second element is a term describing the version
8945                  of the compiler, or undefined if unknown.
8946
8947                check_io:
8948                  Returns  a  list  containing miscellaneous information about
8949                  the emulators internal I/O checking. Notice that the content
8950                  of  the  returned  list  can vary between platforms and over
8951                  time. It is only guaranteed that a list is returned.
8952
8953                compat_rel:
8954                  Returns the compatibility mode of the local node as an inte‐
8955                  ger.  The integer returned represents the Erlang/OTP release
8956                  that the current emulator has been set to be  backward  com‐
8957                  patible  with.  The  compatibility mode can be configured at
8958                  startup by using command-line flag +R in erl(1).
8959
8960                debug_compiled:
8961                  Returns true if the emulator has been debug-compiled, other‐
8962                  wise false.
8963
8964                driver_version:
8965                  Returns  a  string containing the Erlang driver version used
8966                  by the runtime system. It has the form  "<major  ver>.<minor
8967                  ver>".
8968
8969                dynamic_trace:
8970                  Returns  an atom describing the dynamic trace framework com‐
8971                  piled into the virtual machine. It can be dtrace, systemtap,
8972                  or  none.  For  a commercial or standard build, it is always
8973                  none. The other return values indicate a  custom  configura‐
8974                  tion (for example, ./configure --with-dynamic-trace=dtrace).
8975                  For more information about dynamic tracing, see  dyntrace(3)
8976                  manual  page and the README.dtrace/README.systemtap files in
8977                  the Erlang source code top directory.
8978
8979                dynamic_trace_probes:
8980                  Returns a  boolean()  indicating  if  dynamic  trace  probes
8981                  (dtrace  or systemtap) are built into the emulator. This can
8982                  only be true if the virtual machine was  built  for  dynamic
8983                  tracing  (that is, system_info(dynamic_trace) returns dtrace
8984                  or systemtap).
8985
8986                info:
8987                  Returns a binary containing a string of miscellaneous system
8988                  information  formatted  as  in  Erlang crash dumps. For more
8989                  information, see section  How to interpret the Erlang  crash
8990                  dumps in the User's Guide.
8991
8992                kernel_poll:
8993                  Returns  true  if the emulator uses some kind of kernel-poll
8994                  implementation, otherwise false.
8995
8996                loaded:
8997                  Returns a binary containing a string of loaded module infor‐
8998                  mation formatted as in Erlang crash dumps. For more informa‐
8999                  tion, see section How to interpret the Erlang crash dumps in
9000                  the User's Guide.
9001
9002                machine:
9003                  Returns a string containing the Erlang machine name.
9004
9005                modified_timing_level:
9006                  Returns  the  modified timing-level (an integer) if modified
9007                  timing is enabled, otherwise undefined. For more information
9008                  about modified timing, see command-line flag +T in erl(1)
9009
9010                nif_version:
9011                  Returns  a  string  containing the version of the Erlang NIF
9012                  interface used by the runtime system.  It  is  on  the  form
9013                  "<major ver>.<minor ver>".
9014
9015                otp_release:
9016
9017
9018                  Returns  a  string  containing the OTP release number of the
9019                  OTP release that the currently executing ERTS application is
9020                  part of.
9021
9022                  As from Erlang/OTP 17, the OTP release number corresponds to
9023                  the major OTP version number. No erlang:system_info()  argu‐
9024                  ment  gives the exact OTP version. This is because the exact
9025                  OTP version in the general case is difficult  to  determine.
9026                  For  more  information,  see  the description of versions in
9027                  System principles in System Documentation.
9028
9029                port_parallelism:
9030                  Returns the default port parallelism scheduling  hint  used.
9031                  For  more  information,  see  command-line  argument +spp in
9032                  erl(1).
9033
9034                system_architecture:
9035                  Returns a string containing the processor and  OS  architec‐
9036                  ture the emulator is built for.
9037
9038                system_logger:
9039                  Returns  the  current  system_logger  as  set by erlang:sys‐
9040                  tem_flag(system_logger, _).
9041
9042                system_version:
9043                  Returns a string containing version number and  some  impor‐
9044                  tant properties, such as the number of schedulers.
9045
9046                trace_control_word:
9047                  Returns  the  value of the node trace control word. For more
9048                  information, see function get_tcw in section  Match Specifi‐
9049                  cations in Erlang in the User's Guide.
9050
9051                version:
9052                  Returns a string containing the version number of the emula‐
9053                  tor.
9054
9055                wordsize:
9056                  Same as {wordsize, internal}.
9057
9058                {wordsize, internal}:
9059                  Returns the size of Erlang term words in bytes as  an  inte‐
9060                  ger,  that is, 4 is returned on a 32-bit architecture, and 8
9061                  is returned on a pure 64-bit  architecture.  On  a  halfword
9062                  64-bit  emulator,  4  is  returned,  as the Erlang terms are
9063                  stored using a virtual word size of  half  the  system  word
9064                  size.
9065
9066                {wordsize, external}:
9067                  Returns  the  true  word  size of the emulator, that is, the
9068                  size of a pointer. The value is given in bytes as  an  inte‐
9069                  ger. On a pure 32-bit architecture, 4 is returned. On both a
9070                  half word and on a pure 64-bit architecture, 8 is returned.
9071
9072       erlang:system_monitor() -> MonSettings
9073
9074              Types:
9075
9076                 MonSettings = undefined | {MonitorPid, Options}
9077                 MonitorPid = pid()
9078                 Options = [system_monitor_option()]
9079                 system_monitor_option() =
9080                     busy_port | busy_dist_port |
9081                     {long_gc, integer() >= 0} |
9082                     {long_schedule, integer() >= 0} |
9083                     {large_heap, integer() >= 0}
9084
9085              Returns  the  current  system   monitoring   settings   set   by
9086              erlang:system_monitor/2  as  {MonitorPid, Options}, or undefined
9087              if no settings exist. The order of the options can be  different
9088              from the one that was set.
9089
9090       erlang:system_monitor(Arg) -> MonSettings
9091
9092              Types:
9093
9094                 Arg = MonSettings = undefined | {MonitorPid, Options}
9095                 MonitorPid = pid()
9096                 Options = [system_monitor_option()]
9097                 system_monitor_option() =
9098                     busy_port | busy_dist_port |
9099                     {long_gc, integer() >= 0} |
9100                     {long_schedule, integer() >= 0} |
9101                     {large_heap, integer() >= 0}
9102
9103              When called with argument undefined, all system performance mon‐
9104              itoring settings are cleared.
9105
9106              Calling the function with {MonitorPid, Options} as  argument  is
9107              the same as calling erlang:system_monitor(MonitorPid, Options).
9108
9109              Returns   the   previous   system  monitor  settings  just  like
9110              erlang:system_monitor/0.
9111
9112       erlang:system_monitor(MonitorPid, Options) -> MonSettings
9113
9114              Types:
9115
9116                 MonitorPid = pid()
9117                 Options = [system_monitor_option()]
9118                 MonSettings = undefined | {OldMonitorPid, OldOptions}
9119                 OldMonitorPid = pid()
9120                 OldOptions = [system_monitor_option()]
9121                 system_monitor_option() =
9122                     busy_port | busy_dist_port |
9123                     {long_gc, integer() >= 0} |
9124                     {long_schedule, integer() >= 0} |
9125                     {large_heap, integer() >= 0}
9126
9127              Sets the system performance monitoring options. MonitorPid is  a
9128              local  process  identifier  (pid)  receiving system monitor mes‐
9129              sages. The second argument is a list of monitoring options:
9130
9131                {long_gc, Time}:
9132                  If a garbage collection in the system takes  at  least  Time
9133                  wall clock milliseconds, a message {monitor, GcPid, long_gc,
9134                  Info} is sent to MonitorPid.  GcPid  is  the  pid  that  was
9135                  garbage  collected.  Info  is  a  list of two-element tuples
9136                  describing the result of the garbage collection.
9137
9138                  One of the tuples is {timeout, GcTime}, where GcTime is  the
9139                  time  for  the garbage collection in milliseconds. The other
9140                  tuples   are   tagged   with   heap_size,   heap_block_size,
9141                  stack_size,        mbuf_size,       old_heap_size,       and
9142                  old_heap_block_size.  These  tuples  are  explained  in  the
9143                  description    of    trace   message   gc_minor_start   (see
9144                  erlang:trace/3). New tuples can be added, and the  order  of
9145                  the tuples in the Info list can be changed at any time with‐
9146                  out prior notice.
9147
9148                {long_schedule, Time}:
9149                  If a process or port in the system runs uninterrupted for at
9150                  least  Time  wall  clock  milliseconds,  a message {monitor,
9151                  PidOrPort,  long_schedule,  Info}  is  sent  to  MonitorPid.
9152                  PidOrPort is the process or port that was running. Info is a
9153                  list of two-element tuples describing the event.
9154
9155                  If a pid(), the tuples {timeout,  Millis},  {in,  Location},
9156                  and {out, Location} are present, where Location is either an
9157                  MFA ({Module,  Function,  Arity})  describing  the  function
9158                  where  the  process  was scheduled in/out, or the atom unde‐
9159                  fined.
9160
9161                  If a port(), the tuples {timeout, Millis}  and  {port_op,Op}
9162                  are  present. Op is one of proc_sig, timeout, input, output,
9163                  event, or dist_cmd, depending on which driver  callback  was
9164                  executing.
9165
9166                  proc_sig  is  an  internal operation and is never to appear,
9167                  while the others represent the  corresponding  driver  call‐
9168                  backs timeout, ready_input, ready_output, event, and outputv
9169                  (when the port is used by  distribution).  Value  Millis  in
9170                  tuple timeout informs about the uninterrupted execution time
9171                  of the process or port, which always is equal to  or  higher
9172                  than  the  Time  value supplied when starting the trace. New
9173                  tuples can be added to the Info list in  a  future  release.
9174                  The  order  of  the tuples in the list can be changed at any
9175                  time without prior notice.
9176
9177                  This can be used to detect problems  with  NIFs  or  drivers
9178                  that  take  too  long  to execute. 1 ms is considered a good
9179                  maximum time for a driver callback  or  a  NIF.  However,  a
9180                  time-sharing  system is usually to consider everything < 100
9181                  ms as "possible" and fairly "normal". However, longer sched‐
9182                  ule times can indicate swapping or a misbehaving NIF/driver.
9183                  Misbehaving NIFs and drivers can cause bad resource utiliza‐
9184                  tion and bad overall system performance.
9185
9186                {large_heap, Size}:
9187                  If  a  garbage collection in the system results in the allo‐
9188                  cated size of a heap being at least Size  words,  a  message
9189                  {monitor,  GcPid,  large_heap,  Info} is sent to MonitorPid.
9190                  GcPid and Info are the same as for long_gc  earlier,  except
9191                  that the tuple tagged with timeout is not present.
9192
9193                  The  monitor  message is sent if the sum of the sizes of all
9194                  memory blocks allocated for all  heap  generations  after  a
9195                  garbage collection is equal to or higher than Size.
9196
9197                  When  a  process  is  killed  by max_heap_size, it is killed
9198                  before the garbage collection is complete and thus no  large
9199                  heap message is sent.
9200
9201                busy_port:
9202                  If  a  process in the system gets suspended because it sends
9203                  to a busy port, a message {monitor, SusPid, busy_port, Port}
9204                  is  sent to MonitorPid. SusPid is the pid that got suspended
9205                  when sending to Port.
9206
9207                busy_dist_port:
9208                  If a process in the system gets suspended because  it  sends
9209                  to a process on a remote node whose inter-node communication
9210                  was handled by a busy  port,  a  message  {monitor,  SusPid,
9211                  busy_dist_port,  Port}  is sent to MonitorPid. SusPid is the
9212                  pid that got suspended when sending through  the  inter-node
9213                  communication port Port.
9214
9215              Returns   the   previous   system  monitor  settings  just  like
9216              erlang:system_monitor/0.
9217
9218              The arguments to system_monitor/2 specifies how all system moni‐
9219              toring on the node should be done, not how it should be changed.
9220              This means only one process at a time (MonitorPid)  can  be  the
9221              receiver  of  system  monitor messages. Also, the way to clear a
9222              specific monitor option  is  to  not  include  it  in  the  list
9223              Options.  All system monitoring will, however, be cleared if the
9224              process identified by MonitorPid terminates.
9225
9226              There are no special option  values  (like  zero)  to  clear  an
9227              option.  Some  of  the options have a unspecified minimum value.
9228              Lower values will be adjusted to the minimum value. For example,
9229              it  is currently not possible to monitor all garbage collections
9230              with {long_gc, 0}.
9231
9232          Note:
9233              If a monitoring process gets so large that it itself  starts  to
9234              cause  system monitor messages when garbage collecting, the mes‐
9235              sages enlarge the process message queue and  probably  make  the
9236              problem worse.
9237
9238              Keep the monitoring process neat and do not set the system moni‐
9239              tor limits too tight.
9240
9241
9242              Failures:
9243
9244                badarg:
9245                  If MonitorPid does not exist.
9246
9247                badarg:
9248                  If MonitorPid is not a local process.
9249
9250       erlang:system_profile() -> ProfilerSettings
9251
9252              Types:
9253
9254                 ProfilerSettings = undefined | {ProfilerPid, Options}
9255                 ProfilerPid = pid() | port()
9256                 Options = [system_profile_option()]
9257                 system_profile_option() =
9258                     exclusive | runnable_ports | runnable_procs | scheduler |
9259                     timestamp | monotonic_timestamp | strict_monotonic_timestamp
9260
9261              Returns the current system profiling settings set by erlang:sys‐
9262              tem_profile/2  as  {ProfilerPid, Options}, or undefined if there
9263              are no settings. The order of the options can be different  from
9264              the one that was set.
9265
9266       erlang:system_profile(ProfilerPid, Options) -> ProfilerSettings
9267
9268              Types:
9269
9270                 ProfilerPid = pid() | port() | undefined
9271                 Options = [system_profile_option()]
9272                 ProfilerSettings =
9273                     undefined | {pid() | port(), [system_profile_option()]}
9274                 system_profile_option() =
9275                     exclusive | runnable_ports | runnable_procs | scheduler |
9276                     timestamp | monotonic_timestamp | strict_monotonic_timestamp
9277
9278              Sets  system  profiler  options.  ProfilerPid is a local process
9279              identifier (pid)  or  port  receiving  profiling  messages.  The
9280              receiver  is excluded from all profiling. The second argument is
9281              a list of profiling options:
9282
9283                exclusive:
9284                  If a synchronous call to a port from a process is done,  the
9285                  calling  process  is considered not runnable during the call
9286                  runtime to the port. The  calling  process  is  notified  as
9287                  inactive, and later active when the port callback returns.
9288
9289                monotonic_timestamp:
9290                  Time  stamps  in profile messages use Erlang monotonic time.
9291                  The time stamp (Ts) has the same format and  value  as  pro‐
9292                  duced by erlang:monotonic_time(nanosecond).
9293
9294                runnable_procs:
9295                  If  a  process  is put into or removed from the run queue, a
9296                  message, {profile, Pid, State, Mfa, Ts}, is sent to  Profil‐
9297                  erPid.  Running  processes  that are reinserted into the run
9298                  queue after having been pre-empted do not trigger this  mes‐
9299                  sage.
9300
9301                runnable_ports:
9302                  If  a port is put into or removed from the run queue, a mes‐
9303                  sage, {profile, Port, State, 0, Ts}, is sent to ProfilerPid.
9304
9305                scheduler:
9306                  If a scheduler is put to sleep or awoken, a  message,  {pro‐
9307                  file,  scheduler,  Id, State, NoScheds, Ts}, is sent to Pro‐
9308                  filerPid.
9309
9310                strict_monotonic_timestamp:
9311                  Time stamps in profile messages consist of Erlang  monotonic
9312                  time  and a monotonically increasing integer. The time stamp
9313                  (Ts)  has  the  same  format  and  value  as   produced   by
9314                  {erlang:monotonic_time(nanosecond),      erlang:unique_inte‐
9315                  ger([monotonic])}.
9316
9317                timestamp:
9318                  Time stamps in profile messages include a  time  stamp  (Ts)
9319                  that  has the same form as returned by erlang:now(). This is
9320                  also the default if no time  stamp  flag  is  specified.  If
9321                  cpu_timestamp  has been enabled through erlang:trace/3, this
9322                  also effects the time stamp produced in  profiling  messages
9323                  when flag timestamp is enabled.
9324
9325          Note:
9326              erlang:system_profile behavior can change in a future release.
9327
9328
9329       erlang:system_time() -> integer()
9330
9331              Returns current  Erlang system time in native time unit.
9332
9333              Calling   erlang:system_time()  is  equivalent  to  erlang:mono‐
9334              tonic_time() + erlang:time_offset().
9335
9336          Note:
9337              This time is not a monotonically increasing time in the  general
9338              case.  For more information, see the documentation of  time warp
9339              modes in the User's Guide.
9340
9341
9342       erlang:system_time(Unit) -> integer()
9343
9344              Types:
9345
9346                 Unit = time_unit()
9347
9348              Returns current  Erlang system  time  converted  into  the  Unit
9349              passed as argument.
9350
9351              Calling  erlang:system_time(Unit)  is  equivalent to erlang:con‐
9352              vert_time_unit(erlang:system_time(), native, Unit).
9353
9354          Note:
9355              This time is not a monotonically increasing time in the  general
9356              case.  For more information, see the documentation of  time warp
9357              modes in the User's Guide.
9358
9359
9360       term_to_binary(Term) -> ext_binary()
9361
9362              Types:
9363
9364                 Term = term()
9365
9366              Returns a binary data object that is the result of encoding Term
9367              according to the Erlang external term format.
9368
9369              This  can  be  used for various purposes, for example, writing a
9370              term to a file in an efficient way, or sending an Erlang term to
9371              some type of communications channel not supported by distributed
9372              Erlang.
9373
9374              > Bin = term_to_binary(hello).
9375              <<131,100,0,5,104,101,108,108,111>>
9376              > hello = binary_to_term(Bin).
9377              hello
9378
9379
9380              See also binary_to_term/1.
9381
9382          Note:
9383              There is no guarantee that this function will  return  the  same
9384              encoded representation for the same term.
9385
9386
9387       term_to_binary(Term, Options) -> ext_binary()
9388
9389              Types:
9390
9391                 Term = term()
9392                 Options =
9393                     [compressed |
9394                      {compressed, Level :: 0..9} |
9395                      {minor_version, Version :: 0..2}]
9396
9397              Returns a binary data object that is the result of encoding Term
9398              according to the Erlang external term format.
9399
9400              If option compressed is provided, the external  term  format  is
9401              compressed. The compressed format is automatically recognized by
9402              binary_to_term/1 as from Erlang/OTP R7B.
9403
9404              A compression level can be  specified  by  giving  option  {com‐
9405              pressed, Level}. Level is an integer with range 0..9, where:
9406
9407                * 0 - No compression is done (it is the same as giving no com‐
9408                  pressed option).
9409
9410                * 1 - Takes least time but may not compress  as  well  as  the
9411                  higher levels.
9412
9413                * 6 - Default level when option compressed is provided.
9414
9415                * 9  -  Takes most time and tries to produce a smaller result.
9416                  Notice "tries" in the preceding sentence; depending  on  the
9417                  input term, level 9 compression either does or does not pro‐
9418                  duce a smaller result than level 1 compression.
9419
9420              Option {minor_version, Version} can  be  used  to  control  some
9421              encoding  details.  This  option  was  introduced  in Erlang/OTP
9422              R11B-4. The valid values for Version are:
9423
9424                0:
9425                  Floats are encoded  using  a  textual  representation.  This
9426                  option  is  useful to ensure that releases before Erlang/OTP
9427                  R11B-4 can decode resulting binary.
9428
9429                  This version encode atoms  that  can  be  represented  by  a
9430                  latin1  string  using  latin1 encoding while only atoms that
9431                  cannot be represented by latin1 are encoded using utf8.
9432
9433                1:
9434                  This is as of Erlang/OTP 17.0 the  default.  It  forces  any
9435                  floats  in  the term to be encoded in a more space-efficient
9436                  and exact way (namely in the 64-bit IEEE format, rather than
9437                  converted  to  a textual representation). As from Erlang/OTP
9438                  R11B-4, binary_to_term/1 can decode this representation.
9439
9440                  This version encode atoms  that  can  be  represented  by  a
9441                  latin1  string  using  latin1 encoding while only atoms that
9442                  cannot be represented by latin1 are encoded using utf8.
9443
9444                2:
9445                  Drops usage of the latin1 atom encoding and  unconditionally
9446                  use utf8 encoding for all atoms. This will be changed to the
9447                  default in a future major release of Erlang/OTP.  Erlang/OTP
9448                  systems as of R16B can decode this representation.
9449
9450              See also binary_to_term/1.
9451
9452       term_to_iovec(Term) -> ext_iovec()
9453
9454              Types:
9455
9456                 Term = term()
9457
9458              Returns  the  encoding  of Term according to the Erlang external
9459              term format as ext_iovec().
9460
9461              This function produce the same encoding as term_to_binary/1, but
9462              with       another       return       type.       The       call
9463              iolist_to_binary(term_to_iovec(Term)) will produce  exactly  the
9464              same result as the call term_to_binary(Term).
9465
9466              term_to_iovec()  is  a  pure  optimization  of the functionality
9467              term_to_binary() provide. term_to_iovec() can for example  refer
9468              directly to off heap binaries instead of copying the binary data
9469              into the result.
9470
9471              See also term_to_binary/1.
9472
9473       term_to_iovec(Term, Options) -> ext_iovec()
9474
9475              Types:
9476
9477                 Term = term()
9478                 Options =
9479                     [compressed |
9480                      {compressed, Level :: 0..9} |
9481                      {minor_version, Version :: 0..2}]
9482
9483              Returns the encoding of Term according to  the  Erlang  external
9484              term format as ext_iovec().
9485
9486              This function produce the same encoding as term_to_binary/2, but
9487              with       another       return       type.       The       call
9488              iolist_to_binary(term_to_iovec(Term, Opts)) will produce exactly
9489              the same result as term_to_binary(Term, Opts).
9490
9491              Currently recognised  options  are  all  options  recognised  by
9492              term_to_binary/2.
9493
9494              term_to_iovec()  is  a  pure  optimization  of the functionality
9495              term_to_binary() provide. term_to_iovec() can for example  refer
9496              directly to off heap binaries instead of copying the binary data
9497              into the result.
9498
9499              See also term_to_binary/2.
9500
9501       throw(Any) -> no_return()
9502
9503              Types:
9504
9505                 Any = term()
9506
9507              A non-local return from a function. If evaluated within a catch,
9508              catch returns value Any. Example:
9509
9510              > catch throw({hello, there}).
9511              {hello,there}
9512
9513              Failure: nocatch if not evaluated within a catch.
9514
9515       time() -> Time
9516
9517              Types:
9518
9519                 Time = calendar:time()
9520
9521              Returns the current time as {Hour, Minute, Second}.
9522
9523              The  time zone and Daylight Saving Time correction depend on the
9524              underlying OS. Example:
9525
9526              > time().
9527              {9,42,44}
9528
9529       erlang:time_offset() -> integer()
9530
9531              Returns the current time offset between  Erlang  monotonic  time
9532              and  Erlang system time in native time unit. Current time offset
9533              added to an Erlang monotonic  time  gives  corresponding  Erlang
9534              system time.
9535
9536              The time offset may or may not change during operation depending
9537              on the time warp mode used.
9538
9539          Note:
9540              A change in time offset can be observed  at  slightly  different
9541              points in time by different processes.
9542
9543              If  the runtime system is in multi-time warp mode, the time off‐
9544              set is changed when the runtime system detects that the OS  sys‐
9545              tem  time  has  changed.  The  runtime system will, however, not
9546              detect this immediately when it occurs. A task checking the time
9547              offset is scheduled to execute at least once a minute; so, under
9548              normal operation this is to be detected  within  a  minute,  but
9549              during heavy load it can take longer time.
9550
9551
9552       erlang:time_offset(Unit) -> integer()
9553
9554              Types:
9555
9556                 Unit = time_unit()
9557
9558              Returns  the  current time offset between  Erlang monotonic time
9559              and  Erlang system time converted into the Unit passed as  argu‐
9560              ment.
9561
9562              Same  as  calling erlang:convert_time_unit(erlang:time_offset(),
9563              native, Unit) however optimized for commonly used Units.
9564
9565       erlang:timestamp() -> Timestamp
9566
9567              Types:
9568
9569                 Timestamp = timestamp()
9570                 timestamp() =
9571                     {MegaSecs :: integer() >= 0,
9572                      Secs :: integer() >= 0,
9573                      MicroSecs :: integer() >= 0}
9574
9575              Returns current  Erlang system time  on  the  format  {MegaSecs,
9576              Secs,  MicroSecs}. This format is the same as os:timestamp/0 and
9577              the deprecated erlang:now/0 use. The reason for the existence of
9578              erlang:timestamp()  is  purely to simplify use for existing code
9579              that assumes this time stamp format. Current Erlang system  time
9580              can  more  efficiently  be  retrieved  in  the time unit of your
9581              choice using erlang:system_time/1.
9582
9583              The erlang:timestamp() BIF is equivalent to:
9584
9585              timestamp() ->
9586                  ErlangSystemTime = erlang:system_time(microsecond),
9587                  MegaSecs = ErlangSystemTime div 1000_000_000_000,
9588                  Secs = ErlangSystemTime div 1000_000 - MegaSecs*1000_000,
9589                  MicroSecs = ErlangSystemTime rem 1000_000,
9590                  {MegaSecs, Secs, MicroSecs}.
9591
9592              It, however, uses a native implementation that  does  not  build
9593              garbage on the heap and with slightly better performance.
9594
9595          Note:
9596              This  time is not a monotonically increasing time in the general
9597              case. For more information, see the documentation of  time  warp
9598              modes in the User's Guide.
9599
9600
9601       tl(List) -> term()
9602
9603              Types:
9604
9605                 List = [term(), ...]
9606
9607              Returns the tail of List, that is, the list minus the first ele‐
9608              ment, for example:
9609
9610              > tl([geesties, guilies, beasties]).
9611              [guilies, beasties]
9612
9613              Allowed in guard tests.
9614
9615              Failure: badarg if List is the empty list [].
9616
9617       erlang:trace(PidPortSpec, How, FlagList) -> integer()
9618
9619              Types:
9620
9621                 PidPortSpec =
9622                     pid() |
9623                     port() |
9624                     all | processes | ports | existing | existing_processes |
9625                     existing_ports | new | new_processes | new_ports
9626                 How = boolean()
9627                 FlagList = [trace_flag()]
9628                 trace_flag() =
9629                     all | send | 'receive' | procs | ports | call | arity |
9630                     return_to | silent | running | exiting | running_procs |
9631                     running_ports | garbage_collection | timestamp |
9632                     cpu_timestamp | monotonic_timestamp |
9633                     strict_monotonic_timestamp | set_on_spawn |
9634                     set_on_first_spawn | set_on_link | set_on_first_link |
9635                     {tracer, pid() | port()} |
9636                     {tracer, module(), term()}
9637
9638              Turns on (if How == true) or off (if How  ==  false)  the  trace
9639              flags  in  FlagList  for the process or processes represented by
9640              PidPortSpec.
9641
9642              PidPortSpec is either a process identifier  (pid)  for  a  local
9643              process, a port identifier, or one of the following atoms:
9644
9645                all:
9646                  All currently existing processes and ports and all that will
9647                  be created in the future.
9648
9649                processes:
9650                  All currently existing processes and all that will  be  cre‐
9651                  ated in the future.
9652
9653                ports:
9654                  All currently existing ports and all that will be created in
9655                  the future.
9656
9657                existing:
9658                  All currently existing processes and ports.
9659
9660                existing_processes:
9661                  All currently existing processes.
9662
9663                existing_ports:
9664                  All currently existing ports.
9665
9666                new:
9667                  All processes and ports that will be created in the future.
9668
9669                new_processes:
9670                  All processes that will be created in the future.
9671
9672                new_ports:
9673                  All ports that will be created in the future.
9674
9675              FlagList can contain any number  of  the  following  flags  (the
9676              "message tags" refers to the list of trace messages):
9677
9678                all:
9679                  Sets  all trace flags except tracer and cpu_timestamp, which
9680                  are in their nature different than the others.
9681
9682                send:
9683                  Traces sending of messages.
9684
9685                  Message tags: send and send_to_non_existing_process.
9686
9687                'receive':
9688                  Traces receiving of messages.
9689
9690                  Message tags: 'receive'.
9691
9692                call:
9693                  Traces certain function calls. Specify which function  calls
9694                  to trace by calling erlang:trace_pattern/3.
9695
9696                  Message tags: call and return_from.
9697
9698                silent:
9699                  Used  with  the  call trace flag. The call, return_from, and
9700                  return_to trace messages are inhibited if this flag is  set,
9701                  but  they are executed as normal if there are match specifi‐
9702                  cations.
9703
9704                  Silent mode is inhibited by executing erlang:trace(_, false,
9705                  [silent|_]), or by a match specification executing the func‐
9706                  tion {silent, false}.
9707
9708                  The silent trace flag facilitates setting up a trace on many
9709                  or  even  all processes in the system. The trace can then be
9710                  activated and  deactivated  using  the  match  specification
9711                  function  {silent,Bool},  giving a high degree of control of
9712                  which functions with which arguments that trigger the trace.
9713
9714                  Message tags: call, return_from, and return_to.  Or  rather,
9715                  the absence of.
9716
9717                return_to:
9718                  Used  with  the  call  trace  flag. Traces the return from a
9719                  traced function back to its caller. Only works for functions
9720                  traced with option local to erlang:trace_pattern/3.
9721
9722                  The  semantics  is  that a trace message is sent when a call
9723                  traced function returns, that  is,  when  a  chain  of  tail
9724                  recursive  calls  ends.  Only  one trace message is sent per
9725                  chain of tail recursive calls, so  the  properties  of  tail
9726                  recursiveness for function calls are kept while tracing with
9727                  this flag. Using call and return_to trace together makes  it
9728                  possible  to  know  exactly in which function a process exe‐
9729                  cutes at any time.
9730
9731                  To get trace messages containing return  values  from  func‐
9732                  tions,  use  the  {return_trace}  match specification action
9733                  instead.
9734
9735                  Message tags: return_to.
9736
9737                procs:
9738                  Traces process-related events.
9739
9740                  Message tags: spawn, spawned,  exit,  register,  unregister,
9741                  link, unlink, getting_linked, and getting_unlinked.
9742
9743                ports:
9744                  Traces port-related events.
9745
9746                  Message  tags:  open,  closed,  register,  unregister,  get‐
9747                  ting_linked, and getting_unlinked.
9748
9749                running:
9750                  Traces scheduling of processes.
9751
9752                  Message tags: in and out.
9753
9754                exiting:
9755                  Traces scheduling of exiting processes.
9756
9757                  Message tags: in_exiting, out_exiting, and out_exited.
9758
9759                running_procs:
9760                  Traces scheduling of processes just like  running.  However,
9761                  this  option  also includes schedule events when the process
9762                  executes within the context of a port without  being  sched‐
9763                  uled out itself.
9764
9765                  Message tags: in and out.
9766
9767                running_ports:
9768                  Traces scheduling of ports.
9769
9770                  Message tags: in and out.
9771
9772                garbage_collection:
9773                  Traces garbage collections of processes.
9774
9775                  Message    tags:   gc_minor_start,   gc_max_heap_size,   and
9776                  gc_minor_end.
9777
9778                timestamp:
9779                  Includes a time stamp in all trace messages. The time  stamp
9780                  (Ts) has the same form as returned by erlang:now().
9781
9782                cpu_timestamp:
9783                  A global trace flag for the Erlang node that makes all trace
9784                  time stamps using flag timestamp to be in CPU time, not wall
9785                  clock  time.  That is, cpu_timestamp is not be used if mono‐
9786                  tonic_timestamp or  strict_monotonic_timestamp  is  enabled.
9787                  Only  allowed  with PidPortSpec==all. If the host machine OS
9788                  does not  support  high-resolution  CPU  time  measurements,
9789                  trace/3  exits  with badarg. Notice that most OS do not syn‐
9790                  chronize this value across cores, so be prepared  that  time
9791                  can seem to go backwards when using this option.
9792
9793                monotonic_timestamp:
9794                  Includes  an  Erlang  monotonic time time stamp in all trace
9795                  messages. The time stamp (Ts) has the same format and  value
9796                  as  produced by erlang:monotonic_time(nanosecond). This flag
9797                  overrides flag cpu_timestamp.
9798
9799                strict_monotonic_timestamp:
9800                  Includes an time stamp consisting of Erlang  monotonic  time
9801                  and  a  monotonically  increasing  integer in all trace mes‐
9802                  sages. The time stamp (Ts) has the same format and value  as
9803                  produced     by     {     erlang:monotonic_time(nanosecond),
9804                  erlang:unique_integer([monotonic])}.  This  flag   overrides
9805                  flag cpu_timestamp.
9806
9807                arity:
9808                  Used  with  the  call trace flag. {M, F, Arity} is specified
9809                  instead of {M, F, Args} in call trace messages.
9810
9811                set_on_spawn:
9812                  Makes any process created by a traced  process  inherit  its
9813                  trace flags, including flag set_on_spawn.
9814
9815                set_on_first_spawn:
9816                  Makes  the first process created by a traced process inherit
9817                  its trace flags, excluding flag set_on_first_spawn.
9818
9819                set_on_link:
9820                  Makes any process linked by a  traced  process  inherit  its
9821                  trace flags, including flag set_on_link.
9822
9823                set_on_first_link:
9824                  Makes  the  first  process  linked  to  by  a traced process
9825                  inherit its trace flags, excluding flag set_on_first_link.
9826
9827                {tracer, Tracer}:
9828                  Specifies where to send the trace messages. Tracer  must  be
9829                  the  process identifier of a local process or the port iden‐
9830                  tifier of a local port.
9831
9832                {tracer, TracerModule, TracerState}:
9833                  Specifies that a tracer module is to be  called  instead  of
9834                  sending  a  trace message. The tracer module can then ignore
9835                  or change the trace message. For  more  details  on  how  to
9836                  write a tracer module, see erl_tracer(3).
9837
9838              If  no tracer is specified, the calling process receives all the
9839              trace messages.
9840
9841              The effect of combining set_on_first_link  with  set_on_link  is
9842              the  same  as set_on_first_link alone. Likewise for set_on_spawn
9843              and set_on_first_spawn.
9844
9845              The tracing process receives the trace messages described in the
9846              following  list.  Pid  is  the  process identifier of the traced
9847              process in which the traced event has occurred. The third  tuple
9848              element is the message tag.
9849
9850              If   flag   timestamp,   strict_monotonic_timestamp,   or  mono‐
9851              tonic_timestamp  is  specified,  the  first  tuple  element   is
9852              trace_ts  instead,  and the time stamp is added as an extra ele‐
9853              ment last in the message tuple. If multiple time stamp flags are
9854              passed,  timestamp  has  precedence  over strict_monotonic_time‐
9855              stamp, which in turn has  precedence  over  monotonic_timestamp.
9856              All  time  stamp  flags are remembered, so if two are passed and
9857              the one with highest precedence later is disabled, the other one
9858              becomes active.
9859
9860              If  a  match  specification  (applicable only for call, send and
9861              'receive' tracing) contains a {message} action function  with  a
9862              non-boolean  value,  that  value is added as an extra element to
9863              the message tuple either in the  last  position  or  before  the
9864              timestamp (if it is present).
9865
9866              Trace messages:
9867
9868                {trace, PidPort, send, Msg, To}:
9869                  When PidPort sends message Msg to process To.
9870
9871                {trace, PidPort, send_to_non_existing_process, Msg, To}:
9872                  When  PidPort  sends message Msg to the non-existing process
9873                  To.
9874
9875                {trace, PidPort, 'receive', Msg}:
9876                  When PidPort receives message Msg. If Msg is  set  to  time-
9877                  out,  a receive statement can have timed out, or the process
9878                  received a message with the payload timeout.
9879
9880                {trace, Pid, call, {M, F, Args}}:
9881                  When Pid calls a traced function. The return values of calls
9882                  are never supplied, only the call and its arguments.
9883
9884                  Trace  flag arity can be used to change the contents of this
9885                  message, so that Arity is specified instead of Args.
9886
9887                {trace, Pid, return_to, {M, F, Arity}}:
9888                  When Pid returns to the specified function. This trace  mes‐
9889                  sage  is  sent if both the flags call and return_to are set,
9890                  and the function is set  to  be  traced  on  local  function
9891                  calls.  The message is only sent when returning from a chain
9892                  of tail recursive function calls, where at  least  one  call
9893                  generated a call trace message (that is, the functions match
9894                  specification matched,  and  {message,  false}  was  not  an
9895                  action).
9896
9897                {trace, Pid, return_from, {M, F, Arity}, ReturnValue}:
9898                  When  Pid  returns  from  the specified function. This trace
9899                  message is sent if flag call is set, and the function has  a
9900                  match  specification  with a return_trace or exception_trace
9901                  action.
9902
9903                {trace, Pid, exception_from, {M, F, Arity}, {Class, Value}}:
9904                  When Pid exits from the specified  function  because  of  an
9905                  exception.  This  trace message is sent if flag call is set,
9906                  and the function has a match specification  with  an  excep‐
9907                  tion_trace action.
9908
9909                {trace, Pid, spawn, Pid2, {M, F, Args}}:
9910                  When  Pid spawns a new process Pid2 with the specified func‐
9911                  tion call as entry point.
9912
9913                  Args is supposed to be the argument list,  but  can  be  any
9914                  term if the spawn is erroneous.
9915
9916                {trace, Pid, spawned, Pid2, {M, F, Args}}:
9917                  When Pid is spawned by process Pid2 with the specified func‐
9918                  tion call as entry point.
9919
9920                  Args is supposed to be the argument list,  but  can  be  any
9921                  term if the spawn is erroneous.
9922
9923                {trace, Pid, exit, Reason}:
9924                  When Pid exits with reason Reason.
9925
9926                {trace, PidPort, register, RegName}:
9927                  When PidPort gets the name RegName registered.
9928
9929                {trace, PidPort, unregister, RegName}:
9930                  When  PidPort  gets  the  name RegName unregistered. This is
9931                  done automatically when a registered process or port exits.
9932
9933                {trace, Pid, link, Pid2}:
9934                  When Pid links to a process Pid2.
9935
9936                {trace, Pid, unlink, Pid2}:
9937                  When Pid removes the link from a process Pid2.
9938
9939                {trace, PidPort, getting_linked, Pid2}:
9940                  When PidPort gets linked to a process Pid2.
9941
9942                {trace, PidPort, getting_unlinked, Pid2}:
9943                  When PidPort gets unlinked from a process Pid2.
9944
9945                {trace, Pid, exit, Reason}:
9946                  When Pid exits with reason Reason.
9947
9948                {trace, Port, open, Pid, Driver}:
9949                  When Pid opens a new port Port with the running Driver.
9950
9951                  Driver is the name of the driver as an atom.
9952
9953                {trace, Port, closed, Reason}:
9954                  When Port closes with Reason.
9955
9956                {trace, Pid, in | in_exiting, {M, F, Arity} | 0}:
9957                  When Pid is scheduled to run. The process runs  in  function
9958                  {M,  F, Arity}. On some rare occasions, the current function
9959                  cannot be determined, then the last element is 0.
9960
9961                {trace, Pid, out | out_exiting | out_exited, {M, F,  Arity}  |
9962                0}:
9963                  When  Pid is scheduled out. The process was running in func‐
9964                  tion {M, F, Arity}. On  some  rare  occasions,  the  current
9965                  function cannot be determined, then the last element is 0.
9966
9967                {trace, Port, in, Command | 0}:
9968                  When  Port  is  scheduled to run. Command is the first thing
9969                  the port will execute, it can however run  several  commands
9970                  before being scheduled out. On some rare occasions, the cur‐
9971                  rent function cannot be determined, then the last element is
9972                  0.
9973
9974                  The  possible  commands  are  call, close, command, connect,
9975                  control, flush, info, link, open, and unlink.
9976
9977                {trace, Port, out, Command | 0}:
9978                  When Port is scheduled out. The last command  run  was  Com‐
9979                  mand. On some rare occasions, the current function cannot be
9980                  determined, then the last element is 0. Command can  contain
9981                  the same commands as in
9982
9983                {trace, Pid, gc_minor_start, Info}:
9984
9985
9986                  Sent when a young garbage collection is about to be started.
9987                  Info is a list of two-element tuples, where the  first  ele‐
9988                  ment is a key, and the second is the value. Do not depend on
9989                  any order of the tuples. The following keys are defined:
9990
9991                  heap_size:
9992                    The size of the used part of the heap.
9993
9994                  heap_block_size:
9995                    The size of the memory block used for storing the heap and
9996                    the stack.
9997
9998                  old_heap_size:
9999                    The size of the used part of the old heap.
10000
10001                  old_heap_block_size:
10002                    The  size  of  the  memory  block used for storing the old
10003                    heap.
10004
10005                  stack_size:
10006                    The size of the stack.
10007
10008                  recent_size:
10009                    The size of the data that survived  the  previous  garbage
10010                    collection.
10011
10012                  mbuf_size:
10013                    The  combined  size of message buffers associated with the
10014                    process.
10015
10016                  bin_vheap_size:
10017                    The total size of unique off-heap binaries referenced from
10018                    the process heap.
10019
10020                  bin_vheap_block_size:
10021                    The  total size of binaries allowed in the virtual heap in
10022                    the process before doing a garbage collection.
10023
10024                  bin_old_vheap_size:
10025                    The total size of unique off-heap binaries referenced from
10026                    the process old heap.
10027
10028                  bin_old_vheap_block_size:
10029                    The total size of binaries allowed in the virtual old heap
10030                    in the process before doing a garbage collection.
10031
10032                  All sizes are in words.
10033
10034                {trace, Pid, gc_max_heap_size, Info}:
10035                  Sent when the max_heap_size is reached during  garbage  col‐
10036                  lection.  Info  contains the same kind of list as in message
10037                  gc_start, but the sizes reflect  the  sizes  that  triggered
10038                  max_heap_size to be reached.
10039
10040                {trace, Pid, gc_minor_end, Info}:
10041                  Sent  when  young  garbage collection is finished. Info con‐
10042                  tains the same kind of list as  in  message  gc_minor_start,
10043                  but  the  sizes  reflect the new sizes after garbage collec‐
10044                  tion.
10045
10046                {trace, Pid, gc_major_start, Info}:
10047                  Sent when  fullsweep  garbage  collection  is  about  to  be
10048                  started.  Info  contains the same kind of list as in message
10049                  gc_minor_start.
10050
10051                {trace, Pid, gc_major_end, Info}:
10052                  Sent when fullsweep garbage  collection  is  finished.  Info
10053                  contains the same kind of list as in message gc_minor_start,
10054                  but the sizes  reflect  the  new  sizes  after  a  fullsweep
10055                  garbage collection.
10056
10057              If  the  tracing  process/port dies or the tracer module returns
10058              remove, the flags are silently removed.
10059
10060              Each process can  only  be  traced  by  one  tracer.  Therefore,
10061              attempts to trace an already traced process fail.
10062
10063              Returns a number indicating the number of processes that matched
10064              PidPortSpec. If PidPortSpec is a process identifier, the  return
10065              value  is 1. If PidPortSpec is all or existing, the return value
10066              is the number of processes running. If PidPortSpec is  new,  the
10067              return value is 0.
10068
10069              Failure:  badarg  if  the specified arguments are not supported.
10070              For example, cpu_timestamp is not supported on all platforms.
10071
10072       erlang:trace_delivered(Tracee) -> Ref
10073
10074              Types:
10075
10076                 Tracee = pid() | all
10077                 Ref = reference()
10078
10079              The delivery of trace  messages  (generated  by  erlang:trace/3,
10080              seq_trace(3),  or  erlang:system_profile/2) is dislocated on the
10081              time-line compared to other events in the system.  If  you  know
10082              that Tracee has passed some specific point in its execution, and
10083              you want to know when at least all trace messages  corresponding
10084              to  events  up  to  this  point  have  reached  the  tracer, use
10085              erlang:trace_delivered(Tracee).
10086
10087              When it is guaranteed that all trace messages are  delivered  to
10088              the  tracer  up  to the point that Tracee reached at the time of
10089              the call to erlang:trace_delivered(Tracee), then a {trace_deliv‐
10090              ered,   Tracee,   Ref}   message   is  sent  to  the  caller  of
10091              erlang:trace_delivered(Tracee) .
10092
10093              Notice that message trace_delivered does not  imply  that  trace
10094              messages  have been delivered. Instead it implies that all trace
10095              messages that are to be delivered have been delivered. It is not
10096              an  error  if Tracee is not, and has not been traced by someone,
10097              but if this is the case, no trace messages have  been  delivered
10098              when the trace_delivered message arrives.
10099
10100              Notice  that  Tracee must refer to a process currently or previ‐
10101              ously  existing  on   the   same   node   as   the   caller   of
10102              erlang:trace_delivered(Tracee)  resides  on.  The special Tracee
10103              atom all denotes all processes that currently are traced in  the
10104              node.
10105
10106              When  used  together  with a  Tracer Module, any message sent in
10107              the trace callback is guaranteed to have reached  its  recipient
10108              before the trace_delivered message is sent.
10109
10110              Example: Process A is Tracee, port B is tracer, and process C is
10111              the port owner of B. C wants to close B when A exits. To  ensure
10112              that  the trace is not truncated, C can call erlang:trace_deliv‐
10113              ered(A) when A exits, and wait for message {trace_delivered,  A,
10114              Ref} before closing B.
10115
10116              Failure:  badarg  if Tracee does not refer to a process (dead or
10117              alive) on the same node as  the  caller  of  erlang:trace_deliv‐
10118              ered(Tracee) resides on.
10119
10120       erlang:trace_info(PidPortFuncEvent, Item) -> Res
10121
10122              Types:
10123
10124                 PidPortFuncEvent =
10125                     pid() |
10126                     port() |
10127                     new | new_processes | new_ports |
10128                     {Module, Function, Arity} |
10129                     on_load | send | 'receive'
10130                 Module = module()
10131                 Function = atom()
10132                 Arity = arity()
10133                 Item =
10134                     flags | tracer | traced | match_spec | meta |
10135                     meta_match_spec | call_count | call_time | all
10136                 Res = trace_info_return()
10137                 trace_info_return() =
10138                     undefined |
10139                     {flags, [trace_info_flag()]} |
10140                     {tracer, pid() | port() | []} |
10141                     {tracer, module(), term()} |
10142                     trace_info_item_result() |
10143                     {all, [trace_info_item_result()] | false | undefined}
10144                 trace_info_item_result() =
10145                     {traced, global | local | false | undefined} |
10146                     {match_spec, trace_match_spec() | false | undefined} |
10147                     {meta, pid() | port() | false | undefined | []} |
10148                     {meta, module(), term()} |
10149                     {meta_match_spec, trace_match_spec() | false | undefined} |
10150                     {call_count, integer() >= 0 | boolean() | undefined} |
10151                     {call_time,
10152                      [{pid(),
10153                        integer() >= 0,
10154                        integer() >= 0,
10155                        integer() >= 0}] |
10156                      boolean() |
10157                      undefined}
10158                 trace_info_flag() =
10159                     send | 'receive' | set_on_spawn | call | return_to | procs |
10160                     set_on_first_spawn | set_on_link | running |
10161                     garbage_collection | timestamp | monotonic_timestamp |
10162                     strict_monotonic_timestamp | arity
10163                 trace_match_spec() =
10164                     [{[term()] | '_' | match_variable(), [term()], [term()]}]
10165                 match_variable() = atom()
10166                    Approximation of '$1' | '$2' | '$3' | ...
10167
10168              Returns  trace  information  about a port, process, function, or
10169              event.
10170
10171              To get information about a port or process, PidPortFuncEvent  is
10172              to be a process identifier (pid), port identifier, or one of the
10173              atoms new, new_processes, or new_ports. The atom new or new_pro‐
10174              cesses  means  that  the default trace state for processes to be
10175              created is returned. The atom new_ports means that  the  default
10176              trace state for ports to be created is returned.
10177
10178              Valid Items for ports and processes:
10179
10180                flags:
10181                  Returns  a  list  of atoms indicating what kind of traces is
10182                  enabled for the process. The list is empty if no traces  are
10183                  enabled,  and  one or more of the followings atoms if traces
10184                  are enabled: send, 'receive', set_on_spawn, call, return_to,
10185                  procs, ports, set_on_first_spawn, set_on_link, running, run‐
10186                  ning_procs, running_ports, silent, exiting,  monotonic_time‐
10187                  stamp, strict_monotonic_timestamp, garbage_collection, time‐
10188                  stamp, and arity. The order is arbitrary.
10189
10190                tracer:
10191                  Returns the identifier for process, port, or  a  tuple  con‐
10192                  taining  the  tracer  module  and  tracer state tracing this
10193                  process. If this process is not traced, the return value  is
10194                  [].
10195
10196              To  get  information about a function, PidPortFuncEvent is to be
10197              the three-element tuple {Module, Function, Arity}  or  the  atom
10198              on_load.  No  wildcards  are  allowed.  Returns undefined if the
10199              function does not exist, or false if the function is not traced.
10200              If  PidPortFuncEvent is on_load, the information returned refers
10201              to the default value for code that will be loaded.
10202
10203              Valid Items for functions:
10204
10205                traced:
10206                  Returns global if this function is traced on global function
10207                  calls,  local  if  this function is traced on local function
10208                  calls (that is, local and global function calls), and  false
10209                  if local or global function calls are not traced.
10210
10211                match_spec:
10212                  Returns the match specification for this function, if it has
10213                  one. If the function is locally or globally traced  but  has
10214                  no match specification defined, the returned value is [].
10215
10216                meta:
10217                  Returns the meta-trace tracer process, port, or trace module
10218                  for this function, if it has one. If  the  function  is  not
10219                  meta-traced, the returned value is false. If the function is
10220                  meta-traced but has once detected that the tracer process is
10221                  invalid, the returned value is [].
10222
10223                meta_match_spec:
10224                  Returns  the  meta-trace  match specification for this func‐
10225                  tion, if it has one. If the function is meta-traced but  has
10226                  no match specification defined, the returned value is [].
10227
10228                call_count:
10229                  Returns  the  call count value for this function or true for
10230                  the pseudo function on_load if call count tracing is active.
10231                  Otherwise false is returned.
10232
10233                  See also erlang:trace_pattern/3.
10234
10235                call_time:
10236                  Returns  the  call time values for this function or true for
10237                  the pseudo function on_load if call time tracing is  active.
10238                  Otherwise  false is returned. The call time values returned,
10239                  [{Pid, Count, S, Us}], is a list of each process  that  exe‐
10240                  cuted the function and its specific counters.
10241
10242                  See also erlang:trace_pattern/3.
10243
10244                all:
10245                  Returns  a  list containing the {Item, Value} tuples for all
10246                  other items, or returns false if no tracing  is  active  for
10247                  this function.
10248
10249              To get information about an event, PidPortFuncEvent is to be one
10250              of the atoms send or 'receive'.
10251
10252              One valid Item for events exists:
10253
10254                match_spec:
10255                  Returns the match specification for this event,  if  it  has
10256                  one, or true if no match specification has been set.
10257
10258              The  return value is {Item, Value}, where Value is the requested
10259              information as described earlier. If a pid for  a  dead  process
10260              was  specified, or the name of a non-existing function, Value is
10261              undefined.
10262
10263       erlang:trace_pattern(MFA, MatchSpec) -> integer() >= 0
10264
10265              Types:
10266
10267                 MFA = trace_pattern_mfa() | send | 'receive'
10268                 MatchSpec =
10269                     (MatchSpecList :: trace_match_spec()) |
10270                     boolean() |
10271                     restart | pause
10272                 trace_pattern_mfa() = {atom(), atom(), arity() | '_'} | on_load
10273                 trace_match_spec() =
10274                     [{[term()] | '_' | match_variable(), [term()], [term()]}]
10275                 match_variable() = atom()
10276                    Approximation of '$1' | '$2' | '$3' | ...
10277
10278              The same as erlang:trace_pattern(Event, MatchSpec, []), retained
10279              for backward compatibility.
10280
10281       erlang:trace_pattern(MFA :: send, MatchSpec, FlagList :: []) ->
10282                               integer() >= 0
10283
10284              Types:
10285
10286                 MatchSpec = (MatchSpecList :: trace_match_spec()) | boolean()
10287                 trace_match_spec() =
10288                     [{[term()] | '_' | match_variable(), [term()], [term()]}]
10289                 match_variable() = atom()
10290                    Approximation of '$1' | '$2' | '$3' | ...
10291
10292              Sets  trace  pattern  for message sending. Must be combined with
10293              erlang:trace/3 to set the send trace flag for one or  more  pro‐
10294              cesses.  By default all messages sent from send traced processes
10295              are traced. To limit traced send events  based  on  the  message
10296              content,  the  sender and/or the receiver, use erlang:trace_pat‐
10297              tern/3.
10298
10299              Argument MatchSpec can take the following forms:
10300
10301                MatchSpecList:
10302                  A list of match specifications. The matching is done on  the
10303                  list  [Receiver, Msg]. Receiver is the process or port iden‐
10304                  tity of the receiver and Msg is the message term. The pid of
10305                  the  sending process can be accessed with the guard function
10306                  self/0. An empty list is the same as true. For more informa‐
10307                  tion,  see  section   Match  Specifications in Erlang in the
10308                  User's Guide.
10309
10310                true:
10311                  Enables tracing for all sent messages (from send traced pro‐
10312                  cesses).  Any  match  specification  is removed. This is the
10313                  default.
10314
10315                false:
10316                  Disables tracing for all sent messages. Any match specifica‐
10317                  tion is removed.
10318
10319              Argument FlagList must be [] for send tracing.
10320
10321              The return value is always 1.
10322
10323              Examples:
10324
10325              Only trace messages to a specific process Pid:
10326
10327              > erlang:trace_pattern(send, [{[Pid, '_'],[],[]}], []).
10328              1
10329
10330              Only trace messages matching {reply, _}:
10331
10332              > erlang:trace_pattern(send, [{['_', {reply,'_'}],[],[]}], []).
10333              1
10334
10335              Only trace messages sent to the sender itself:
10336
10337              > erlang:trace_pattern(send, [{['$1', '_'],[{'=:=','$1',{self}}],[]}], []).
10338              1
10339
10340              Only trace messages sent to other nodes:
10341
10342              > erlang:trace_pattern(send, [{['$1', '_'],[{'=/=',{node,'$1'},{node}}],[]}], []).
10343              1
10344
10345          Note:
10346              A  match specification for send trace can use all guard and body
10347              functions except caller.
10348
10349
10350              Fails by raising an error exception with an error reason of:
10351
10352                badarg:
10353                  If an argument is invalid.
10354
10355                system_limit:
10356                  If a match specification passed as  argument  has  excessive
10357                  nesting  which  causes  scheduler  stack  exhaustion for the
10358                  scheduler that the calling process is executing  on.  Sched‐
10359                  uler  stack size can be configured when starting the runtime
10360                  system.
10361
10362       erlang:trace_pattern(MFA :: 'receive', MatchSpec, FlagList :: []) ->
10363                               integer() >= 0
10364
10365              Types:
10366
10367                 MatchSpec = (MatchSpecList :: trace_match_spec()) | boolean()
10368                 trace_match_spec() =
10369                     [{[term()] | '_' | match_variable(), [term()], [term()]}]
10370                 match_variable() = atom()
10371                    Approximation of '$1' | '$2' | '$3' | ...
10372
10373              Sets trace pattern for message receiving. Must be combined  with
10374              erlang:trace/3  to  set the 'receive' trace flag for one or more
10375              processes. By default all messages received by 'receive'  traced
10376              processes  are  traced.  To limit traced receive events based on
10377              the  message  content,  the  sender  and/or  the  receiver,  use
10378              erlang:trace_pattern/3.
10379
10380              Argument MatchSpec can take the following forms:
10381
10382                MatchSpecList:
10383                  A  list of match specifications. The matching is done on the
10384                  list [Node, Sender, Msg]. Node  is  the  node  name  of  the
10385                  sender.  Sender  is  the  process  or  port  identity of the
10386                  sender, or the atom undefined if the  sender  is  not  known
10387                  (which  can be the case for remote senders). Msg is the mes‐
10388                  sage term. The pid of the receiving process can be  accessed
10389                  with the guard function self/0. An empty list is the same as
10390                  true. For more information, see  section   Match  Specifica‐
10391                  tions in Erlang in the User's Guide.
10392
10393                true:
10394                  Enables  tracing  for  all  received  messages (to 'receive'
10395                  traced processes). Any match specification is removed.  This
10396                  is the default.
10397
10398                false:
10399                  Disables tracing for all received messages. Any match speci‐
10400                  fication is removed.
10401
10402              Argument FlagList must be [] for receive tracing.
10403
10404              The return value is always 1.
10405
10406              Examples:
10407
10408              Only trace messages from a specific process Pid:
10409
10410              > erlang:trace_pattern('receive', [{['_',Pid, '_'],[],[]}], []).
10411              1
10412
10413              Only trace messages matching {reply, _}:
10414
10415              > erlang:trace_pattern('receive', [{['_','_', {reply,'_'}],[],[]}], []).
10416              1
10417
10418              Only trace messages from other nodes:
10419
10420              > erlang:trace_pattern('receive', [{['$1', '_', '_'],[{'=/=','$1',{node}}],[]}], []).
10421              1
10422
10423          Note:
10424              A match specification for 'receive' trace can use all guard  and
10425              body   functions  except  caller,  is_seq_trace,  get_seq_token,
10426              set_seq_token, enable_trace, disable_trace, trace,  silent,  and
10427              process_dump.
10428
10429
10430              Fails by raising an error exception with an error reason of:
10431
10432                badarg:
10433                  If an argument is invalid.
10434
10435                system_limit:
10436                  If  a  match  specification passed as argument has excessive
10437                  nesting which causes  scheduler  stack  exhaustion  for  the
10438                  scheduler  that  the calling process is executing on. Sched‐
10439                  uler stack size can be configured when starting the  runtime
10440                  system.
10441
10442       erlang:trace_pattern(MFA, MatchSpec, FlagList) ->
10443                               integer() >= 0
10444
10445              Types:
10446
10447                 MFA = trace_pattern_mfa()
10448                 MatchSpec =
10449                     (MatchSpecList :: trace_match_spec()) |
10450                     boolean() |
10451                     restart | pause
10452                 FlagList = [trace_pattern_flag()]
10453                 trace_pattern_mfa() = {atom(), atom(), arity() | '_'} | on_load
10454                 trace_match_spec() =
10455                     [{[term()] | '_' | match_variable(), [term()], [term()]}]
10456                 trace_pattern_flag() =
10457                     global | local | meta |
10458                     {meta, Pid :: pid()} |
10459                     {meta, TracerModule :: module(), TracerState :: term()} |
10460                     call_count | call_time
10461                 match_variable() = atom()
10462                    Approximation of '$1' | '$2' | '$3' | ...
10463
10464              Enables or disables call tracing for one or more functions. Must
10465              be combined with erlang:trace/3 to set the call trace  flag  for
10466              one or more processes.
10467
10468              Conceptually,  call  tracing works as follows. Inside the Erlang
10469              virtual machine, a set of processes and a set of  functions  are
10470              to  be  traced. If a traced process calls a traced function, the
10471              trace action is taken. Otherwise, nothing happens.
10472
10473              To add or remove one or more processes to the set of traced pro‐
10474              cesses, use erlang:trace/3.
10475
10476              To  add  or remove functions to the set of traced functions, use
10477              erlang:trace_pattern/3.
10478
10479              The BIF erlang:trace_pattern/3 can also add match specifications
10480              to  a  function.  A match specification comprises a pattern that
10481              the function arguments must match, a guard expression that  must
10482              evaluate  to  true,  and  an action to be performed. The default
10483              action is to send a trace message. If the pattern does not match
10484              or the guard fails, the action is not executed.
10485
10486              Argument  MFA  is  to  be  a  tuple,  such as {Module, Function,
10487              Arity}, or the atom on_load (described below).  It  can  be  the
10488              module, function, and arity for a function (or a BIF in any mod‐
10489              ule). The atom '_' can be used as a wildcard in any of the  fol‐
10490              lowing ways:
10491
10492                {Module,Function,'_'}:
10493                  All functions of any arity named Function in module Module.
10494
10495                {Module,'_','_'}:
10496                  All functions in module Module.
10497
10498                {'_','_','_'}:
10499                  All functions in all loaded modules.
10500
10501              Other combinations, such as {Module,'_',Arity}, are not allowed.
10502              Local functions match wildcards  only  if  option  local  is  in
10503              FlagList.
10504
10505              If argument MFA is the atom on_load, the match specification and
10506              flag list are used on all modules that are newly loaded.
10507
10508              Argument MatchSpec can take the following forms:
10509
10510                false:
10511                  Disables tracing for the matching functions. Any match spec‐
10512                  ification is removed.
10513
10514                true:
10515                  Enables tracing for the matching functions. Any match speci‐
10516                  fication is removed.
10517
10518                MatchSpecList:
10519                  A list of match specifications. An empty list is  equivalent
10520                  to true. For a description of match specifications, see sec‐
10521                  tion  Match Specifications in Erlang in the User's Guide.
10522
10523                restart:
10524                  For the FlagList options call_count and call_time:  restarts
10525                  the  existing  counters. The behavior is undefined for other
10526                  FlagList options.
10527
10528                pause:
10529                  For the FlagList options call_count  and  call_time:  pauses
10530                  the  existing  counters. The behavior is undefined for other
10531                  FlagList options.
10532
10533              Parameter FlagList is a list of options. The following  are  the
10534              valid options:
10535
10536                global:
10537                  Turns on or off call tracing for global function calls (that
10538                  is, calls specifying the module explicitly).  Only  exported
10539                  functions  match  and  only global calls generate trace mes‐
10540                  sages. This is the default.
10541
10542                local:
10543                  Turns on or off call  tracing  for  all  types  of  function
10544                  calls. Trace messages are sent whenever any of the specified
10545                  functions are called, regardless of how they are called.  If
10546                  flag  return_to  is set for the process, a return_to message
10547                  is also sent when this function returns to its caller.
10548
10549                meta | {meta, Pid} | {meta, TracerModule, TracerState}:
10550                  Turns on or off  meta-tracing  for  all  types  of  function
10551                  calls. Trace messages are sent to the tracer whenever any of
10552                  the specified functions are called. If no tracer  is  speci‐
10553                  fied, self() is used as a default tracer process.
10554
10555                  Meta-tracing  traces  all  processes and does not care about
10556                  the process trace flags set  by  erlang:trace/3,  the  trace
10557                  flags are instead fixed to [call, timestamp].
10558
10559                  The  match  specification function {return_trace} works with
10560                  meta-trace and sends its trace message to the same tracer.
10561
10562                call_count:
10563                  Starts (MatchSpec == true) or  stops  (MatchSpec  ==  false)
10564                  call  count  tracing  for  all  types of function calls. For
10565                  every function, a counter is incremented when  the  function
10566                  is called, in any process. No process trace flags need to be
10567                  activated.
10568
10569                  If call count tracing is started while already running,  the
10570                  count is restarted from zero. To pause running counters, use
10571                  MatchSpec == pause.  Paused  and  running  counters  can  be
10572                  restarted from zero with MatchSpec == restart.
10573
10574                  To read the counter value, use erlang:trace_info/2.
10575
10576                call_time:
10577                  Starts  (MatchSpec  ==  true)  or stops (MatchSpec == false)
10578                  call time tracing for all types of function calls. For every
10579                  function,  a  counter  is  incremented  when the function is
10580                  called. Time spent in the function  is  accumulated  in  two
10581                  other  counters,  seconds and microseconds. The counters are
10582                  stored for each call traced process.
10583
10584                  If call time tracing is started while already  running,  the
10585                  count and time restart from zero. To pause running counters,
10586                  use MatchSpec == pause. Paused and running counters  can  be
10587                  restarted from zero with MatchSpec == restart.
10588
10589                  To read the counter value, use erlang:trace_info/2.
10590
10591              The  options global and local are mutually exclusive, and global
10592              is the default  (if  no  options  are  specified).  The  options
10593              call_count  and meta perform a kind of local tracing, and cannot
10594              be combined with global. A function can be globally  or  locally
10595              traced.  If  global tracing is specified for a set of functions,
10596              then local, meta, call time, and  call  count  tracing  for  the
10597              matching set of local functions is disabled, and conversely.
10598
10599              When  disabling  trace,  the option must match the type of trace
10600              set on the function. That is, local  tracing  must  be  disabled
10601              with  option  local and global tracing with option global (or no
10602              option), and so on.
10603
10604              Part of a match specification list cannot be  changed  directly.
10605              If a function has a match specification, it can be replaced with
10606              a new one. To change an existing match  specification,  use  the
10607              BIF  erlang:trace_info/2 to retrieve the existing match specifi‐
10608              cation.
10609
10610              Returns the number of functions matching argument MFA.  This  is
10611              zero if none matched.
10612
10613              Fails by raising an error exception with an error reason of:
10614
10615                badarg:
10616                  If an argument is invalid.
10617
10618                system_limit:
10619                  If  a  match  specification passed as argument has excessive
10620                  nesting which causes  scheduler  stack  exhaustion  for  the
10621                  scheduler  that  the calling process is executing on. Sched‐
10622                  uler stack size can be configured when starting the  runtime
10623                  system.
10624
10625       trunc(Number) -> integer()
10626
10627              Types:
10628
10629                 Number = number()
10630
10631              Returns an integer by truncating Number, for example:
10632
10633              > trunc(5.5).
10634              5
10635
10636              Allowed in guard tests.
10637
10638       tuple_size(Tuple) -> integer() >= 0
10639
10640              Types:
10641
10642                 Tuple = tuple()
10643
10644              Returns  an integer that is the number of elements in Tuple, for
10645              example:
10646
10647              > tuple_size({morni, mulle, bwange}).
10648              3
10649
10650              Allowed in guard tests.
10651
10652       tuple_to_list(Tuple) -> [term()]
10653
10654              Types:
10655
10656                 Tuple = tuple()
10657
10658              Returns a list corresponding to Tuple.  Tuple  can  contain  any
10659              Erlang terms. Example:
10660
10661              > tuple_to_list({share, {'Ericsson_B', 163}}).
10662              [share,{'Ericsson_B',163}]
10663
10664       erlang:unique_integer() -> integer()
10665
10666              Generates and returns an  integer unique on current runtime sys‐
10667              tem instance. The same as calling erlang:unique_integer([]).
10668
10669       erlang:unique_integer(ModifierList) -> integer()
10670
10671              Types:
10672
10673                 ModifierList = [Modifier]
10674                 Modifier = positive | monotonic
10675
10676              Generates and returns an  integer unique on current runtime sys‐
10677              tem  instance. The integer is unique in the sense that this BIF,
10678              using the same set of modifiers, does not return the same  inte‐
10679              ger  more than once on the current runtime system instance. Each
10680              integer value can of course be constructed by other means.
10681
10682              By default, when [] is passed as ModifierList, both negative and
10683              positive  integers  can  be  returned.  This to use the range of
10684              integers that do not need heap memory allocation as much as pos‐
10685              sible. By default the returned integers are also only guaranteed
10686              to be unique, that is, any returned integer can  be  smaller  or
10687              larger than previously returned integers.
10688
10689              Modifiers:
10690
10691                positive:
10692                  Returns only positive integers.
10693
10694                  Notice  that  by  passing the positive modifier you will get
10695                  heap allocated integers (bignums) quicker.
10696
10697                monotonic:
10698                  Returns  strictly monotonically increasing  integers  corre‐
10699                  sponding  to creation time. That is, the integer returned is
10700                  always larger than previously returned integers on the  cur‐
10701                  rent runtime system instance.
10702
10703                  These  values  can be used to determine order between events
10704                  on the runtime  system  instance.  That  is,  if  both  X  =
10705                  erlang:unique_integer([monotonic])       and       Y       =
10706                  erlang:unique_integer([monotonic]) are executed by different
10707                  processes  (or  the same process) on the same runtime system
10708                  instance and X < Y, we know that X was created before Y.
10709
10710            Warning:
10711                Strictly monotonically increasing values are inherently  quite
10712                expensive  to  generate and scales poorly. This is because the
10713                values need to be synchronized between CPU cores. That is,  do
10714                not  pass  the  monotonic  modifier  unless  you  really  need
10715                strictly monotonically increasing values.
10716
10717
10718              All valid Modifiers can be combined. Repeated (valid)  Modifiers
10719              in the ModifierList are ignored.
10720
10721          Note:
10722              The  set  of  integers returned by erlang:unique_integer/1 using
10723              different sets of Modifiers will overlap. For example, by  call‐
10724              ing  unique_integer([monotonic]),  and unique_integer([positive,
10725              monotonic]) repeatedly, you will eventually  see  some  integers
10726              that are returned by both calls.
10727
10728
10729              Failures:
10730
10731                badarg:
10732                  if ModifierList is not a proper list.
10733
10734                badarg:
10735                  if Modifier is not a valid modifier.
10736
10737       erlang:universaltime() -> DateTime
10738
10739              Types:
10740
10741                 DateTime = calendar:datetime()
10742
10743              Returns  the  current  date and time according to Universal Time
10744              Coordinated (UTC)  in  the  form  {{Year,  Month,  Day},  {Hour,
10745              Minute,  Second}}  if  supported by the underlying OS. Otherwise
10746              erlang:universaltime()  is  equivalent  to   erlang:localtime().
10747              Example:
10748
10749              > erlang:universaltime().
10750              {{1996,11,6},{14,18,43}}
10751
10752       erlang:universaltime_to_localtime(Universaltime) -> Localtime
10753
10754              Types:
10755
10756                 Localtime = Universaltime = calendar:datetime()
10757
10758              Converts Universal Time Coordinated (UTC) date and time to local
10759              date and time in the form {{Year, Month,  Day},  {Hour,  Minute,
10760              Second}} if supported by the underlying OS. Otherwise no conver‐
10761              sion is done, and Universaltime is returned. Example:
10762
10763              > erlang:universaltime_to_localtime({{1996,11,6},{14,18,43}}).
10764              {{1996,11,7},{15,18,43}}
10765
10766              Failure: badarg if Universaltime denotes  an  invalid  date  and
10767              time.
10768
10769       unlink(Id) -> true
10770
10771              Types:
10772
10773                 Id = pid() | port()
10774
10775              Removes  a  link between the calling process and another process
10776              or a port identified by Id. We will from here on call the  iden‐
10777              tified process or port unlinkee.
10778
10779              A  link can be set up using the link/1 BIF. For more information
10780              on links and exit signals due to links, see the Processes  chap‐
10781              ter in the Erlang Reference Manual :
10782
10783                * Links
10784
10785                * Sending Exit Signals
10786
10787                * Receiving Exit Signals
10788
10789              Once  unlink(Id)  has  returned,  it is guaranteed that the link
10790              between the caller and the unlinkee has no effect on the  caller
10791              in the future (unless the link is setup again). Note that if the
10792              caller is trapping exits, an {'EXIT',  Id,  ExitReason}  message
10793              due to the link may have been placed in the message queue of the
10794              caller before the unlink(Id) call completed. Also note that  the
10795              {'EXIT',  Id, ExitReason} message may be the result of the link,
10796              but may also be the result of the unlikee sending the caller  an
10797              exit  signal by calling the exit/2 BIF. Therefore, it may or may
10798              not be appropriate to clean up the message queue after a call to
10799              unlink(Id) as follows, when trapping exits:
10800
10801              unlink(Id),
10802              receive
10803                  {'EXIT', Id, _} ->
10804                      true
10805              after 0 ->
10806                      true
10807              end
10808
10809              The  link  removal  is  performed asynchronously. If such a link
10810              does not exist, nothing is done. A detailed description  of  the
10811              link protocol can be found in the Distribution Protocol  chapter
10812              of the ERTS User's Guide .
10813
10814              Failure: badarg if Id does not identify  a  process  or  a  node
10815              local port.
10816
10817       unregister(RegName) -> true
10818
10819              Types:
10820
10821                 RegName = atom()
10822
10823              Removes  the  registered  name RegName associated with a process
10824              identifier or a port identifier, for example:
10825
10826              > unregister(db).
10827              true
10828
10829              Users are advised not to unregister system processes.
10830
10831              Failure: badarg if RegName is not a registered name.
10832
10833       whereis(RegName) -> pid() | port() | undefined
10834
10835              Types:
10836
10837                 RegName = atom()
10838
10839              Returns the process identifier or port identifier with the  reg‐
10840              istered  name RegName. Returns undefined if the name is not reg‐
10841              istered. Example:
10842
10843              > whereis(db).
10844              <0.43.0>
10845
10846       erlang:yield() -> true
10847
10848              Voluntarily lets other processes (if any) get a chance  to  exe‐
10849              cute.  Using this function is similar to receive after 1 -> true
10850              end, except that yield() is faster.
10851
10852          Warning:
10853              There is seldom or never any need to use this BIF as other  pro‐
10854              cesses  have a chance to run in another scheduler thread anyway.
10855              Using this BIF without a thorough grasp  of  how  the  scheduler
10856              works can cause performance degradation.
10857
10858
10859
10860
10861Ericsson AB                        erts 11.2                         erlang(3)
Impressum