r4493@vps: verhaegs | 2007-04-19 14:44:00 -0400
[AROS.git] / rom / exec / childstatus.c
blob2cb8b1e3b50e75c7f69bbabf981eae1783b866b5
1 /*
2 Copyright © 1995-2001, 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(APTR, 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 this is _NOT_
28 a task pointer.
30 RESULT
31 One of the CHILD_* values.
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 *****************************************************************************/
45 AROS_LIBFUNC_INIT
46 AROS_LIBBASE_EXT_DECL(struct ExecBase *,SysBase)
48 struct Task *this;
49 struct ETask *et;
50 struct ETask *child;
51 ULONG status = CHILD_NOTFOUND;
53 this = FindTask(NULL);
54 if ((this->tc_Flags & TF_ETASK) == 0)
55 return CHILD_NOTNEW;
57 et = this->tc_UnionETask.tc_ETask;
59 /* Sigh... */
60 Forbid();
62 /* Search through the running tasks list */
63 ForeachNode(&et->et_Children, child)
65 if (child->et_UniqueID == (ULONG)tid)
67 status = CHILD_ACTIVE;
68 break;
72 ForeachNode(&et->et_TaskMsgPort.mp_MsgList, child)
74 if (child->et_UniqueID == (ULONG)tid)
76 status = CHILD_EXITED;
77 break;
81 Permit();
82 return status;
84 AROS_LIBFUNC_EXIT
85 } /* ChildStatus */