I have an application that ran fine in Elixir 1.14, OTP 25, but has a problem in Elixir 1.17, OTP 26. I am on Ubuntu 22.04. The application opens a Port to an executable (rscript) that performs some calculations, and sends data back to Elixir through stdout. The process that opens the port is a GenServer (supervised in a DynamicSupervisor). On init, the GenSerer calls Process.flag(:trap_exit, true). Then the port is opened with Port.open(…, :exit_status}, and is monitored with Port.monitor. In Elixir 1.14, the GenServer process receives {port, {:exit_status, 0}} and then {:EXIT, port, :normal} messages when the rscript process terminates.
However in a build of the application under Elixir 1.17, after running for a second or two the rscript finds that its standard output pipe is broken (it receives a SIGPIPE signal). Then the Elixir GenServer process never gets the {port, {:exit_status, status}} message, and when it does receive the {:EXIT, from, :normal} message, the “from” is not the port, but instead is a pid for a process that I cannot find anywhere in the OTP logs.
I assume that newly opened Ports must create some internal process, and that is the process that is dying.
But why is it dying only in Eliixr 1.17/OTP 26, and not in the earlier versions? Could it be that the rscript is trying to write to stderr (which OTP ports don’t connect to)? Are ports set up differently in OTP 26 than in OTP 25?