Questions tagged [erlang]

Erlang is a general-purpose, garbage-collected programming language and runtime environment, with built-in support for concurrency, distribution and fault tolerance.

Erlang is a general-purpose functional programming language and runtime environment. It has built-in support for concurrency, distribution and fault tolerance. Erlang is used in several large telecommunication systems from Ericsson. Erlang is open source and available for download on GitHub.

Some Erlang features:

Online Resources:

Erlang Books:

9600 questions
5
votes
2 answers

Why does my Erlang boot script work from console but does not work when run from init system (sysvinit, upstart, systemd)?

I have an Erlang boot script that I can launch like this: /usr/bin/erl -boot /path/to/my-boot-script It works when run from console, but fails without any error messages when I run it from systemd. The systemd unit file looks like…
Shnatsel
  • 4,008
  • 1
  • 24
  • 25
5
votes
1 answer

production env does not find OTP module :httpc when using exrm

I'm trying to create a release for my phoenix-framework project. Everything is working fine, until my code need to do a specific action using :httpc module from OTP. Apparently exrm, hasn't bundled the httpc module, and therefore could not find…
TheSquad
  • 7,385
  • 8
  • 40
  • 79
5
votes
2 answers

Type of non-terminating function in Erlang

I'm learning Erlang and trying to use Dialyzer to get maximum type-safety when it's possible. There's a thing that I don't understand: what is the type of non-terminating function and how to denote it in -spec. Could anyone shed some light on this?
ppopoff
  • 658
  • 7
  • 17
5
votes
2 answers

Erlang: Read from an input stream in a efficient way

I'm writing a program that reads from an input stream, i.e. erl -run p main -noshell -s erlang halt < input The problem is that it takes a lot of time to read it (the input stream is huge) using this read function: read_input(L) -> case…
5
votes
3 answers

erlang mnesia - illegal record info

I am trying to have a function that ensures the table I need is already created and if not to create it. Here's the sample: ensure_table_exists(Table, MnesiaTables, Nodes) -> case lists:member(Table, MnesiaTables) of true -> …
hyperboreean
  • 8,273
  • 12
  • 61
  • 97
5
votes
1 answer

Why does Dialyzer not catch this simple error?

Dialyzer does not signal the inconsistency in the return type of this function: -spec myfun(integer()) -> zero | one. myfun(0) -> zero; myfun(1) -> one; myfun(2) -> other_number. but it detects in the case of the last line being myfun(_) ->…
mljrg
  • 4,430
  • 2
  • 36
  • 49
5
votes
3 answers

In Erlang, when a process's mailbox growth bigger, it runs slower, why?

Here is the example:test_for_gen_server.erl When a process got 10000 messages in its mailbox, it took 0.043 sec to finish. When the number is 50000, it should take 0.215 sec, but the reality is 2.4 sec, 10 times slower. Why? Erlang/OTP 18 [erts-7.1]…
5
votes
2 answers

How to read all the records of mnesia database in erlang?

I ma new in erlang and I need to do some operations for all records I get from mnesia database. Result = mnesia:dirty_read(mydatabase, {key1, key2}), case Result of [] -> ?DEBUG("No such record found", []); …
Besat
  • 1,428
  • 13
  • 27
5
votes
1 answer

How to catch a control-c to the Erlang shell?

I am running a gen_server and I want to do some cleanup before it exits. When I run this from the command line, I'm given an Erlang shell prompt. I have a handle_info({'EXIT'}, From, Reason}, and a terminate(Reason, State) in the gen_server…
Turtle V. Rabbit
  • 313
  • 1
  • 3
  • 8
5
votes
2 answers

Why should I monitor processes and not just link and trap exits?

Besides avoiding propagated kills, is there any advantage to monitoring over just trapping exits?
ForeverConfused
  • 1,607
  • 3
  • 26
  • 41
5
votes
2 answers

How to start a gen_server or gen_fsm on demand in Erlang without race conditions?

I need to spawn several independent instances of the same gen_fsm on demand, and then be able to route calls to the correct instance. Gproc library seems to be a great way of registering processes with arbitrary names. It has a function…
Shnatsel
  • 4,008
  • 1
  • 24
  • 25
5
votes
1 answer

Erlang, converting xml to tuples and lists

I'm trying to create key, value pair tuples out of xml. I'd like to make a list out of any nested xml. It seems like a very common thing to do, but I can't find any examples. For instance: The…
brian
  • 105
  • 4
5
votes
2 answers

rebar3: dependency is not reachable

I was trying to convert a REST API example built using rebar to rebar3 release (http://jordenlowe.com/title/Explain_like_I_am_5_-_Erlang_REST_Framework_Cowboy). I have added jsx to app.src. What could be the reason for this? Also is there anything I…
Pavanan M S
  • 157
  • 1
  • 2
  • 13
5
votes
1 answer

Erlang: create a disc schema

If an Erlang application, myapp, requires mnesia to run, then mnesia should be included in its application resource file, under key applications, so that if myapp is started, mnesia would get started automatically - it's node type by default is…
Not an ID
  • 2,579
  • 2
  • 21
  • 28
5
votes
2 answers

Stopping of Erlang app hangs when mnesia stopped from within the program

I've run into a problem where I cannot stop mnesia within my program without causing the app to hang. I'm presently doing prototyping of mnesia within my erlang app. In my jaus_app.erl file the start() calls: {atomic, ok} =…
Ken Robinson
  • 153
  • 2
  • 5