ExTermbox.ProcessManager (ExTermbox v1.1.2)

View Source

Manages the lifecycle of the C helper process and the PortHandler GenServer.

Provides functions to:

  • Spawn the Port process (spawn_port_process/2)
  • Connect to the socket exposed by the C helper (connect_socket/1)
  • Send commands to the C helper via the Port (send_command_to_port/2)
  • Manage the socket connection (manage_socket_connection/1)

Summary

Functions

Uses Port.close to close the port.

Uses :gen_tcp.close for closing the UDS created via :gen_tcp.

Uses Port.command to send data to the port process.

Connects to a Unix Domain Socket at the given path.

Uses :gen_tcp.send for sending data over the UDS connection established with :gen_tcp.connect.

Uses Port.open to start the C port process.

Functions

close_port(port)

Uses Port.close to close the port.

close_socket(socket)

Uses :gen_tcp.close for closing the UDS created via :gen_tcp.

command_port(port, data)

Uses Port.command to send data to the port process.

connect_socket(path, timeout \\ 5000)

@spec connect_socket(Path.t(), pos_integer()) ::
  {:ok, :socket.socket()} | {:error, any()}

Connects to a Unix Domain Socket at the given path.

send_socket(socket, data)

Uses :gen_tcp.send for sending data over the UDS connection established with :gen_tcp.connect.

spawn_port(command, args \\ [], opts \\ [])

Uses Port.open to start the C port process.

Opts: [:binary, :exit_status, :nouse_stdio]

  • :binary - data is sent/received as binaries
  • :exit_status - receive a message when the port exits
  • :nouse_stdio - prevent port from interacting with group leader stdio