revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / childorphan.c
blob3ba2e6653bc0bd74c0eb80b6a8d309087a0e2a3b
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Make any children of this task orphans.
6 Lang: english
7 */
8 #include "exec_intern.h"
9 #include "exec_util.h"
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
16 AROS_LH1(ULONG, ChildOrphan,
18 /* SYNOPSIS */
19 AROS_LHA(ULONG, tid, D0),
21 /* LOCATION */
22 struct ExecBase *, SysBase, 124, Exec)
24 /* FUNCTION
25 ChildOrphan() will detach the specified task from its parent
26 task's child task tree. This is useful if the parent task will be
27 exiting, and no longer needs to be told about child task events.
29 Note that the default Task finaliser will orphan any remaining
30 children when the task exits. This function can be used if you just
31 do not wish to be told about a particular task.
33 INPUTS
34 tid -- The ID of the task to orphan, or 0 for all tasks. Note
35 that it is NOT the pointer to the task.
37 RESULT
38 Will return 0 on success or CHILD_* on an error.
40 The child/children will no longer participate in child task
41 actions.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct Task *ThisTask = GET_THIS_TASK;
58 struct ETask *et, *child;
60 if (ThisTask)
62 et = GetETask(ThisTask);
63 if (et == NULL)
64 return CHILD_NOTNEW;
66 if (tid == 0L)
68 Forbid();
69 ForeachNode(&et->et_Children, child)
72 Don't need to Remove(), because I'll blow away the entire
73 list at the end of the loop.
75 child->et_Parent = NULL;
77 NEWLIST(&et->et_Children);
78 Permit();
80 else
82 Forbid();
83 child = FindChild(tid);
84 if (child != NULL)
86 child->et_Parent = NULL;
87 Remove((struct Node *)child);
89 else
91 Permit();
92 return CHILD_NOTFOUND;
94 Permit();
97 return 0;
99 AROS_LIBFUNC_EXIT
100 } /* ChildOrphan */