erlang_port_info(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– 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} where Pid is the process identifier of the process connected to the port.
  • id β€” returns {id, Index} where Index is 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} where Bytes is the total number of bytes read from the port.
  • links β€” returns {links, Pids} where Pids is 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} where Locking is 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} where Bytes is the total number of bytes allocated for this port by the runtime system. the port itself can have allocated memory that is not included in Bytes. so like, it has secrets. πŸ™ˆ

Since: OTP R16B

  • monitors β€” returns {monitors, Monitors} where Monitors represent processes monitored by this port.

Since: OTP R16B

  • monitored_by β€” returns {monitored_by, MonitoredBy} where MonitoredBy is 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} where Name is the command name set by open_port/2.
  • os_pid β€” returns {os_pid, OsPid} where OsPid is the process identifier (or equivalent) of an OS process created with open_port({spawn | spawn_executable, Command}, Options). if the port is not the result of spawning an OS process, the value is undefined. no OS process, no pid, no cap. πŸ’€

Since: OTP R16B

  • output β€” returns {output, Bytes} where Bytes is the total number of bytes written to the port from Erlang processes using port_command/2, port_command/3, or Port ! {Owner, {command, Data}.
  • parallelism β€” returns {parallelism, Boolean} where Boolean corresponds to the port parallelism hint used by this port. for more info, see the option parallelism of open_port/2.

Since: OTP R16B

  • queue_size β€” returns {queue_size, Bytes} where Bytes is the total number of bytes queued by the port using the ERTS driver queue implementation.

Since: OTP R16B

  • registered_name β€” returns {registered_name, RegisteredName} where RegisteredName is the registered name of the port. if the port has no registered name, [] is returned. anonymous port era. πŸ¦‹

🚨 Failure: badarg if Port is 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