Small cleanup of extensions code
[AROS.git] / compiler / clib / getppid.c
bloba167d79fc2518585e7373406960b7cbc94ccf8dd
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <unistd.h>
7 #include <sys/types.h>
9 #include <exec/tasks.h>
10 #include <proto/exec.h>
12 #include <assert.h>
14 #include "__vfork.h"
15 #include "__arosc_privdata.h"
17 /*****************************************************************************
19 NAME */
21 pid_t getppid(
23 /* SYNOPSIS */
24 void)
26 /* FUNCTION
28 INPUTS
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 struct Task *ParentTask;
45 struct ETask *eThisTask;
46 struct ETask *et;
48 if(__get_arosc_privdata()->acpd_flags & PRETEND_CHILD)
50 struct vfork_data *udata = __get_arosc_privdata()->acpd_vfork_data;
51 eThisTask = GetETask(udata->child);
53 else
54 eThisTask = GetETask(FindTask(NULL));
55 assert(eThisTask);
56 ParentTask = (struct Task *)eThisTask->et_Parent;
57 if(!ParentTask)
58 return (pid_t) 1;
59 et = GetETask(ParentTask);
60 assert(et);
61 return (pid_t) et->et_UniqueID;