Why doesn't Erlang's shell end after all these processes have reached their goal?

At https://github.com/giorgiosironi/erlang-2pc/blob/master/nodes.erl#L95 I start 3 processes that end after the algorithm completes (or I think: their functions return). I also think the start / 0 function is complete.

I trigger this function to execute with: erl -noshell -run nodes test_commit -noshell

After executing the function, I get the expected result: <0.30.0> - As coordinator added cohort: <0.31.0> <0.31.0> - Will propose: yes <0.32.0> - Will propose: yes <0.30.0> - As coordinator added cohort: <0.32.0> <0.30.0> - As coordinator, 1st phase trying to commit <0.31.0> - Queried by coordinator <0.32.0> - Queried by coordinator <0.30.0> - As coordinator received a yes <0.30.0> - As coordinator received a yes <0.30.0> - As coordinator, 2nd phase <0.31.0> - COMMIT! <0.32.0> - COMMIT! <0.30.0> - COMMIT!

but then the shell hangs there indefinitely. I exit with CTRL + C and then (A) bort.

Why doesn't the shell end on its own? How can I check which processes are still there from the shell in this hanging state? If this is ok, how can I programmatically terminate it from my test script?

+3


source to share


1 answer


You need to tell the runtime to stop as soon as it finishes executing your function. One way to do this is to use a function init:stop/0

:

erl -noinput -run nodes test_commit -s init stop

      



Note that the option -noinput

also implies -noshell

.

+5


source







All Articles