How do 开发者_C百科I kill a process in Erlang knowing only the module name used to start it?
If it's for simple debugging, you could run pman:start(), and just look for the process (double-click on an entry to see details such as initial call). You can then kill it from pman directly.
Otherwise, you could use erlang:processes() to list all processes in the system (horrible, I know), and run erlang:process_info(Pid, initial_call) on each of them to find the right process. Once you've done that, just use exit(Pid, kill).
There is no way to do that.
Your best bet is to speculate based on the the registered name and/or the initial call of your processes.
You can still possibly find the process through other means, even if it's not registered. For instance, you could have a look with a process monitor like pman (pman:start()) and see if you find it there. pman allows you to filter for many criteria, which could lead you to the right process. Or you could start up the debugger, install a breakpoint into the module, and next time the process does something, it will be interrupted, the debugger will pop up a window, and in the title bar you can read the PID of the process that was interrupted.
Once you have the PID, you can use pid(A, B, C). to forge a PID object on the shell from it, and use that to kill the process.
精彩评论