xref: /minix/minix/lib/libc/sys/getppid.c (revision 83133719)
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
4 
5 #include <string.h>
6 #include <unistd.h>
7 
8 pid_t getppid(void)
9 {
10   message m;
11 
12   memset(&m, 0, sizeof(m));
13   /* POSIX says that this function is always successful and that no
14    * return value is reserved to indicate an error.  Minix syscalls
15    * are not always successful and Minix returns the reserved value
16    * (pid_t) -1 when there is an error.
17    */
18   if (_syscall(PM_PROC_NR, PM_GETPID, &m) < 0) return(-1);
19   return(m.m_pm_lc_getpid.parent_pid);
20 }
21