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 function definitions. When I control-c in the Erlang shell, neither of these seem to be triggered.
So, how can I catch the control-c entered at the Erlang shell, in my gen_server?
Edit: I've been pressing control-c to get the menu, then control-c again to break out of the shell.
Do you mean that you press CTRL-C
and then (a)bort? CTRL-C
itself is intercepted by Shell to show you the menu. However, when you press abort it stops the Erlang VM unconditionally. You would need to quit the shell gracefully, .e.g. with q().
or init:stop()
.
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