I use Cure to communicate with the port, but the basic settings are:
binary
{packet, 2}
use_stdio
I had an elixir program as the port executable for easy integration with my main application. It would simply pretend to have executed any command I send and give the appropriate response.
In this program I observed lots of weird behavior, like IO.read(2) returning the whole message the port just wrote instead of just 2 bytes of it.
So I replaced it with this:
cat >&2```
I use this as my test executable and observe the same: The first message is written on the stderr (which is unbuffered so I see it immediately) and the second message I'm trying to send never comes through. I also changed for this one `{packet, 2}`into `{line, 256}`to no avail.
Both messages are issued with `Port.command`. Second one always blocks forever.
Is this a port driver issue?
Cure library and ports were totally uninvolved in the end. I gave a function to execute to a GenServer which sync-called into the same GenServer. That deadlocked.