From 098aa2ad54cfa81c07c49ed2a45d38e58bd3ecef Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 12 Apr 2011 16:47:17 +0200 Subject: Allow supervisor:terminate_child(SupRef,Pid) for simple_one_for_one supervisor:terminate_child/2 was not allowed if the supervisor used restart strategy simple_one_for_one. This is now changed so that children of this type of supervisors can be terminated by specifying the child's Pid. --- lib/stdlib/doc/src/supervisor.xml | 43 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/supervisor.xml b/lib/stdlib/doc/src/supervisor.xml index 45fa0847a8..d6203bdaa0 100644 --- a/lib/stdlib/doc/src/supervisor.xml +++ b/lib/stdlib/doc/src/supervisor.xml @@ -4,7 +4,7 @@
- 19962010 + 19962011 Ericsson AB. All Rights Reserved. @@ -83,11 +83,17 @@ supervisor, where all child processes are dynamically added instances of the same process type, i.e. running the same code.

-

The functions terminate_child/2, delete_child/2 +

The functions delete_child/2 and restart_child/2 are invalid for simple_one_for_one supervisors and will return {error,simple_one_for_one} if the specified supervisor uses this restart strategy.

+

The function terminate_child/2 can be used for + children under simple_one_for_one supervisors by + giving the child's pid() as the second argument. If + instead the child specification identifier is used, + terminate_child/2 will return + {error,simple_one_for_one}.

To prevent a supervisor from getting into an infinite loop of @@ -311,24 +317,33 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules} SupRef = Name | {Name,Node} | {global,Name} | pid()  Name = Node = atom() - Id = term() + Id = pid() | term() Result = ok | {error,Error}  Error = not_found | simple_one_for_one -

Tells the supervisor SupRef to terminate the child - process corresponding to the child specification identified - by Id. The process, if there is one, is terminated but - the child specification is kept by the supervisor. This means - that the child process may be later be restarted by - the supervisor. The child process can also be restarted - explicitly by calling restart_child/2. Use - delete_child/2 to remove the child specification.

+

Tells the supervisor SupRef to terminate the given + child.

+

If the supervisor is not simple_one_for_one, + Id must be the child specification identifier. The + process, if there is one, is terminated but the child + specification is kept by the supervisor. The child process + may later be restarted by the supervisor. The child process + can also be restarted explicitly by calling + restart_child/2. Use delete_child/2 to remove + the child specification.

+

If the supervisor is simple_one_for_one, Id + must be the child process' pid(). I the specified + process is alive, but is not a child of the given + supervisor, the function will return + {error,not_found}. If the child specification + identifier is given instead instead of a pid(), the + function will return {error,simple_one_for_one}.

+

If successful, the function returns ok. If there is + no child specification with the specified Id, the + function returns {error,not_found}.

See start_child/2 for a description of SupRef.

-

If successful, the function returns ok. If there is - no child specification with the specified Id, - the function returns {error,not_found}.

-- cgit v1.2.3