summaryrefslogtreecommitdiff
path: root/lib/stdlib/test/shell_docs_SUITE_data/unknown_erlang_monitor_2_func.txt
blob: f5697179454f2350f1c3893b87ad858abf1564f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

  -spec monitor(process, monitor_process_identifier()) -> MonitorRef
                   when MonitorRef :: reference();
               (port, monitor_port_identifier()) -> MonitorRef
                   when MonitorRef :: reference();
               (time_offset, clock_service) -> MonitorRef
                   when MonitorRef :: reference().

Since:
  OTP 18.0,OTP 19.0

  Types:
    -type monitor_port_identifier() :: port() | registered_name().
    -type monitor_process_identifier() ::
          pid() | registered_process_identifier().
    -type registered_name() :: atom().
    -type registered_process_identifier() ::
          registered_name() | {registered_name(), node()}.

  Sends a monitor request of type Type to the entity identified by 
  Item. If the monitored entity does not exist or it changes
  monitored state, the caller of monitor/2 is notified by a
  message on the following format:

    {Tag, MonitorRef, Type, Object, Info}

  Note:
    The monitor request is an asynchronous signal. That is, it
    takes time before the signal reaches its destination.

  Type can be one of the following atoms: process, port or 
  time_offset.

  A process or port monitor is triggered only once, after that
  it is removed from both monitoring process and the monitored
  entity. Monitors are fired when the monitored process or port
  terminates, does not exist at the moment of creation, or if the
  connection to it is lost. If the connection to it is lost, we do
  not know if it still exists. The monitoring is also turned off
  when demonitor/1 is called.

  A process or port monitor by name resolves the RegisteredName
  to pid() or port() only once at the moment of monitor
  instantiation, later changes to the name registration will not
  affect the existing monitor.

  When a process or port monitor is triggered, a 'DOWN'
  message is sent that has the following pattern:

    {'DOWN', MonitorRef, Type, Object, Info}

  In the monitor message MonitorRef and Type are the same as
  described earlier, and:

  Object:
    The monitored entity, which triggered the event. When
    monitoring a process or a local port, Object will be equal
    to the pid() or port() that was being monitored. When
    monitoring process or port by name, Object will have format 
    {RegisteredName, Node} where RegisteredName is the name
    which has been used with monitor/2 call and Node is local
    or remote node name (for ports monitored by name, Node is
    always local node name).

  Info:
    Either the exit reason of the process, noproc (process or
    port did not exist at the time of monitor creation), or 
    noconnection (no connection to the node where the monitored
    process resides).

  Monitoring a process:
    Creates monitor between the current process and another
    process identified by Item, which can be a pid() (local or
    remote), an atom RegisteredName or a tuple {RegisteredName,
    Node} for a registered process, located elsewhere.

    Note:
      Before ERTS 10.0 (OTP 21.0), monitoring a process could
      fail with badarg if the monitored process resided on a
      primitive node (such as erl_interface or jinterface),
      where remote process monitoring is not implemented.

      Now, such a call to monitor will instead succeed and a
      monitor is created. But the monitor will only supervise
      the connection. That is, a {'DOWN', _, process, _,
      noconnection} is the only message that may be received,
      as the primitive node have no way of reporting the status
      of the monitored process.

  Monitoring a port:
    Creates monitor between the current process and a port
    identified by Item, which can be a port() (only local), an
    atom RegisteredName or a tuple {RegisteredName, Node} for
    a registered port, located on this node. Note, that attempt to
    monitor a remote port will result in badarg.

  Monitoring a time_offset:
    Monitors changes in time offset between Erlang monotonic
    time and Erlang system time. One valid Item exists in
    combination with the time_offset Type, namely the atom 
    clock_service. Notice that the atom clock_service is not
    the registered name of a process. In this case it serves as an
    identifier of the runtime system internal clock service at
    current runtime system instance.

    The monitor is triggered when the time offset is changed. This
    either if the time offset value is changed, or if the offset
    is changed from preliminary to final during finalization of
    the time offset when the single time warp mode is used.
    When a change from preliminary to final time offset is made,
    the monitor is triggered once regardless of whether the time
    offset value was changed or not.

    If the runtime system is in multi time warp mode, the time
    offset is changed when the runtime system detects that the OS
    system time has changed. The runtime system does, however,
    not detect this immediately when it occurs. A task checking
    the time offset is scheduled to execute at least once a
    minute, so under normal operation this is to be detected
    within a minute, but during heavy load it can take longer
    time.

    The monitor is not automatically removed after it has been
    triggered. That is, repeated changes of the time offset
    trigger the monitor repeatedly.

    When the monitor is triggered a 'CHANGE' message is sent to
    the monitoring process. A 'CHANGE' message has the following
    pattern:

      {'CHANGE', MonitorRef, Type, Item, NewTimeOffset}

    where MonitorRef, Type, and Item are the same as
    described above, and NewTimeOffset is the new time offset.

    When the 'CHANGE' message has been received you are
    guaranteed not to retrieve the old time offset when calling 
    erlang:time_offset(). Notice that you can observe the change
    of the time offset when calling erlang:time_offset() before
    you get the 'CHANGE' message.

  Making several calls to monitor/2 for the same Item and/or 
  Type is not an error; it results in as many independent
  monitoring instances.

  The monitor functionality is expected to be extended. That is,
  other Types and Items are expected to be supported in a future
  release.

  Note:
    If or when monitor/2 is extended, other possible values for 
    Tag, Object, and Info in the monitor message will be
    introduced.