In https://github.com/giorgiosironi/erlang-2pc/blob/master/nodes.erl#L95 I spawn 3 processes which terminate after the algorithm has finished (or so I think: their functions return). I think also the start/0 function has terminated.
I start the execution of this function with:
erl -noshell -run nodes test_commit -noshell
After executing the function, I get my expected output:
<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 the shell is not terminating by itself? How can I inspect which processes are still alive from the shell in this hanged state? If it's normal, how can I terminate it programmatically from my test script?
You need to tell the runtime to stop once it finishes running your function. One way to do this is to use the init:stop/0 function:
erl -noinput -run nodes test_commit -s init stop
Note that the -noinput option also implies -noshell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With