erlang_port_info(3)
π erlang_port_info π
okay bestie, welcome to erlang_port_info(3) β the part of the Erlang module docs that hands you the tea on a Port. it's giving detective energy, and we're obsessed. let's get into it π΅οΈβοΈβ¨
πΈ NAME πΈ
erlang_port_info β returns information about Port. that's it, that's the whole job, and it does it flawlessly π
β¨ DESCRIPTION β¨
so here's the vibe check first, before we even get to the items:
if the port identified by Port is not open, undefined is returned. simple. iconic. no drama.
and here's the part you need to internalize fr fr: if the port is closed, and the calling process was previously linked to that port, then the exit signal from the port is guaranteed to be delivered before port_info/2 returns undefined. like, the signal is not gonna ghost you β it arrives first, periodt. π«Ά
Item is one of the following, and you use it to pull all kinds of different info about the Port. pick your fighter:
connectedβ returns{connected, Pid}wherePidis the process identifier of the process connected to the port.idβ returns{id, Index}whereIndexis the internal index of the port. this index can be used to separate ports. very "every port has its own government name" of it.inputβ returns{input, Bytes}whereBytesis the total number of bytes read from the port.linksβ returns{links, Pids}wherePidsis a list of the process identifiers of the processes that the port is linked to. port's whole friend group, exposed. πlockingβ returns{locking, Locking}whereLockingis one of the following:port_level(port-specific locking)driver_level(driver-specific locking)
β οΈ notice that these results are highly implementation-specific and can change in a future release. so don't build your whole personality on them, okay?
Since: OTP R16B
memoryβ returns{memory, Bytes}whereBytesis the total number of bytes allocated for this port by the runtime system. the port itself can have allocated memory that is not included inBytes. so like, it has secrets. π
Since: OTP R16B
monitorsβ returns{monitors, Monitors}whereMonitorsrepresent processes monitored by this port.
Since: OTP R16B
monitored_byβ returns{monitored_by, MonitoredBy}whereMonitoredByis a list of pids that are monitoring given port at the moment. right now. currently. live footage. π
Since: OTP 19.0
nameβ returns{name, Name}whereNameis the command name set byopen_port/2.os_pidβ returns{os_pid, OsPid}whereOsPidis the process identifier (or equivalent) of an OS process created withopen_port({spawn | spawn_executable, Command}, Options). if the port is not the result of spawning an OS process, the value isundefined. no OS process, no pid, no cap. π
Since: OTP R16B
outputβ returns{output, Bytes}whereBytesis the total number of bytes written to the port from Erlang processes usingport_command/2,port_command/3, orPort ! {Owner, {command, Data}.parallelismβ returns{parallelism, Boolean}whereBooleancorresponds to the port parallelism hint used by this port. for more info, see the optionparallelismofopen_port/2.
Since: OTP R16B
queue_sizeβ returns{queue_size, Bytes}whereBytesis the total number of bytes queued by the port using the ERTS driver queue implementation.
Since: OTP R16B
registered_nameβ returns{registered_name, RegisteredName}whereRegisteredNameis the registered name of the port. if the port has no registered name,[]is returned. anonymous port era. π¦
π¨ Failure:badargifPortis not a local port identifier, or an atom. try that and it will yell at you, and honestly? deserved.
k that's the whole page bestie, you ate this π mwah! this was brought to you by Ericsson AB, version erts 17.0.6, and it lives in the erlang_port_info(3) section of the manual. go get your port info, you icon, periodt πβ¨π
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms