[erlang-questions] Kill a process tree

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Fri Apr 20 19:02:31 CEST 2007

If the processes were linked to each other and 
not trapping exits, then killing the root should 
kill the others as well.

But you claim that they are not linked...
I wonder what makes it a tree, then.

You could call processes(), and traverse the list
looking for some common element, perhaps 


1> [P || {P,{initial_call,IC}} <-
   [{P1,process_info(P1,initial_call)} ||
     P1 <- processes()],
     IC == {proc_lib,init_p,5}].

Without knowing anything about how the processes
relate to each other, it's a bit difficult to
give advice.

Ulf W

> -----Original Message-----
> From: erlang-questions-bounces@REDACTED 
> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of June Kim
> Sent: den 20 april 2007 18:30
> To: erlang-questions@REDACTED
> Subject: [erlang-questions] Kill a process tree
> Suppose I spawned a process and let's call it "root".
> root will probably spawn a few children, and those children, 
> in turn, would spawn a few grand-children.
> Now, I want to kill the process tree starting from root. How 
> can I achieve it?
> Limitation: the thing is that all the code is written using 
> plain spawn and no consideration was done in the code for 
> this kind of case(such as link). Moreover, you can't change 
> the code. The code for root and so on were written without 
> any regard for this process tree kill. (well, suppose the 
> root and its descendant codes were written by a third-party)
> How can I do it?
> June
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list