pzingg

pzingg

Problem with Port exiting prematurely (with pid :EXIT} in Elixir 1.17/OTP 26 application

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?

First Post!

pzingg

pzingg

I think I will reimplement the Port interface using erlexec where I can trap stderr output more easily. Results to follow, soon I hope.

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement