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

Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
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 record...
New
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement