revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / childstatus.c
blobd23a83ce4d6ee9c9457bde90d71acb11f3c2eca0
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Find out the status of a child task.
6 */
7 #include "exec_intern.h"
8 #include <proto/exec.h>
10 /*****************************************************************************
12 NAME */
14 AROS_LH1(ULONG, ChildStatus,
16 /* SYNOPSIS */
17 AROS_LHA(ULONG, tid, D0),
19 /* LOCATION */
20 struct ExecBase *, SysBase, 125, Exec)
22 /* FUNCTION
23 Return the status of a child task. This allows the Task to
24 determine whether a particular child task is still running or not.
26 INPUTS
27 tid -- The ID of the task to examine. Note that it is _NOT_
28 a task pointer.
30 RESULT
31 One of the CHILD_* values.
33 NOTES
34 This function will work correctly only for child tasks that are
35 processes created with NP_NotifyOnDeath set to TRUE. Otherwise
36 it may report CHILD_NOTFOUND even if child already exited.
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct Task *ThisTask = GET_THIS_TASK;
51 struct ETask *et;
52 struct ETask *child;
53 ULONG status = CHILD_NOTFOUND;
55 if (ThisTask)
57 if ((ThisTask->tc_Flags & TF_ETASK) == 0)
58 return CHILD_NOTNEW;
60 et = ThisTask->tc_UnionETask.tc_ETask;
62 /* Sigh... */
63 Forbid();
65 /* Search through the running tasks list */
66 ForeachNode(&et->et_Children, child)
68 if (child->et_UniqueID == tid)
70 status = CHILD_ACTIVE;
71 break;
75 #if defined(__AROSEXEC_SMP__)
76 EXEC_SPINLOCK_LOCK(&et->et_TaskMsgPort.mp_SpinLock, NULL, SPINLOCK_MODE_READ);
77 #endif
78 ForeachNode(&et->et_TaskMsgPort.mp_MsgList, child)
80 if (child->et_UniqueID == tid)
82 status = CHILD_EXITED;
83 break;
86 #if defined(__AROSEXEC_SMP__)
87 EXEC_SPINLOCK_UNLOCK(&et->et_TaskMsgPort.mp_SpinLock);
88 #endif
89 Permit();
91 return status;
93 AROS_LIBFUNC_EXIT
94 } /* ChildStatus */