Goose97

Goose97

How to stop Erlang VM from polling stdin?

I’m developing a terminal UI application. The structure of the application is like so:

  • Core logic is handled by Elixir
  • Interacting with the terminal (draw, reading events,…) is handled via a NIF

The NIF reads from stdin and translates into keyboard events. The problem is the Erlang VM seems to also reads from stdin, stealing the input from the NIF. Here’s the dtruss output (dtrace wrapper) when running a simple Elixir script with mix run (just enable terminal raw mode and sleep):

select(0x16, 0x1496041B8, 0x0, 0x149604238, 0x16D76ABB8)		 = 1 0

              libsystem_kernel.dylib`__select+0x8
              beam.smp`erts_schedule+0x39bc
              0x143885be0
              0x1439047d8

read(0x0, "b\0", 0x10000)		 = 1 0

              libsystem_kernel.dylib`read+0x8
              beam.smp`erts_port_task_execute+0x980
              beam.smp`erts_schedule+0x3030
              0x143885be0
              0x1439047d8

My theory is that there a separated thread in the VM keep polling on a list of file descriptors (stdin included). The bytes is buffer somewhere and can be retrieved later on, for example IO.read(:stdio, 5).

Is this correct? If so, how can tell the VM to NOT read from the stdin?

Marked As Solved

nhpip

nhpip

I think you should try the Erlang flags -detached and/or -noshell / -noinput.

Take a look at Erlang erl

So:

elixir —erl “-noinput -detached “

Or something close

Also Liked

Goose97

Goose97

Thanks. -noinput does the trick.

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
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
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
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

We're in Beta

About us Mission Statement