Strategy 2: Communicating via I/O with Ports
Ports provide a safer alternative to integrate with external software. Each port starts the third-party software as a separate process in the operating system. If that port terminates, your Elixir code gets a message, and you can act accordingly. A segmentation fault in the external port won’t bring your Elixir system down.
It is possible that you’ve already spawned ports in your Elixir applications, like this:
|||System.cmd("elixir", ["-e", "IO.puts 21 * 2"])|
This command finds the elixir executable in your operating system and invokes it passing the command-line arguments -e, for code evaluation, and the contents IO.puts 21 * 2. Then System.cmd returns the result written to the standard ...