How to kill a process in Erlang, knowing only the name of the module used to start it?

How to kill a process in Erlang, knowing only the name of the module used to start it?

+6
erlang
source share
3 answers

There is no way to do this.

It is best to assume that it is based on the registered name and / or initial call of your processes.

+4
source share

If for simple debugging you can run pman: start () and just search for the process (double-click the entry to see details such as the initial call). Then you can kill it from pman directly.

Otherwise, you can use erlang: processes () to list all the processes in the system (horrible, I know) and run erlang: process_info (Pid, initial_call) for each of them to find the correct process. Once you do this, just use exit (Pid, kill).

+9
source share

You can still find this process using other means, even if it is not registered. For example, you can look at a process monitor such as pman (pman: start ()) and see if you find it there. pman allows you to filter by many criteria, which can lead you to the right process. Or you can run the debugger, set a breakpoint in the module, and the next time the process does something, it will be interrupted, the debugger will open a window, and in the title bar you can read the PID of the process that was interrupted.

Once you have a PID, you can use pid (A, B, C). to create a PID object on the shell from it and use it to kill the process.

+1
source share

All Articles