[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
initial_call?
E.g.
1> [P || {P,{initial_call,IC}} <-
[{P1,process_info(P1,initial_call)} ||
P1 <- processes()],
IC == {proc_lib,init_p,5}].
[<0.4.0>,
<0.7.0>,
<0.9.0>,
<0.10.0>,
<0.11.0>,
<0.14.0>,
<0.16.0>,
<0.17.0>,
<0.19.0>,
<0.24.0>,
<0.25.0>,
<0.28.0>,
<0.30.0>,
<0.31.0>,
<0.32.0>,
<0.33.0>,
<0.34.0>]
Without knowing anything about how the processes
relate to each other, it's a bit difficult to
give advice.
BR,
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