Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang process monitoring itself

I am trying to create a process in Erlang that can monitor itself and restart of it exits. So far I've had no luck at all, so don't have any code to show. Is this even possible in Erlang, and if so how?

Edit: J Fritsch posted a link to a sample that monitors itself but only once. If exit(Doctor, doctor). is used twice it doesn't work the second time. Any ideas on how to get round this?

like image 579
Dean Barnes Avatar asked Dec 22 '22 05:12

Dean Barnes


1 Answers

If the process doing the monitoring is the one doing the dying, you will invariably get yourself into knots.

Use a supervisor.

like image 95
Marcelo Cantos Avatar answered Jan 02 '23 19:01

Marcelo Cantos