forwarding a patch that uses the fetch macros to pull in acpica and build it (NicJA).
[AROS.git] / compiler / posixc / getppid.c
blobb2c57251697c10fe9d74eff46dcbbbadb3f9af20
1 /*
2 Copyright © 2004-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <sys/types.h>
8 #include <exec/tasks.h>
9 #include <proto/exec.h>
11 #include <assert.h>
13 #include "__vfork.h"
14 #include "__posixc_intbase.h"
16 /*****************************************************************************
18 NAME */
19 #include <unistd.h>
21 pid_t getppid(
23 /* SYNOPSIS */
24 void)
26 /* FUNCTION
27 Returns the Parent process ID of the calling processes.
29 INPUTS
31 RESULT
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 ******************************************************************************/
45 struct PosixCIntBase *PosixCBase =
46 (struct PosixCIntBase *)__aros_getbase_PosixCBase();
47 struct Task *ParentTask;
48 struct ETask *eThisTask;
49 struct ETask *et;
51 if(PosixCBase->flags & PRETEND_CHILD)
53 struct vfork_data *udata = PosixCBase->vfork_data;
54 eThisTask = GetETask(udata->child);
56 else
57 eThisTask = GetETask(FindTask(NULL));
58 assert(eThisTask);
59 ParentTask = (struct Task *)eThisTask->et_Parent;
60 if(!ParentTask)
61 return (pid_t) 1;
62 et = GetETask(ParentTask);
63 assert(et);
64 return (pid_t) et->et_UniqueID;