📎 Webclip
See all messages in process's mailbox with pid XY
The thread answers that a process mailbox can be inspected with :erlang.process_info(pid, :messages). It also mentions the Observer application for viewing a message queue snapshot in a GUI, and Erlang tracing tools for watching messages sent to or from processes.
Reading notes#
- :erlang.process_info(pid, :messages) returns the current messages in a process mailbox.
- The example sends :foobar to a process and inspects the mailbox from another process.
- :observer.start can open Observer, where the Processes tab shows a snapshot of the queue.
- :sys, :dbg, and :erlang.trace/3 can be used to trace message flow dynamically.
- Robert Virding warns that reading another process’s mailbox can be costly because the messages are copied.
- He suggests checking Process.info(pid, :message_queue_len) first.
