]> git.lizzy.rs Git - plan9front.git/blob - sys/src/ape/lib/ap/plan9/getppid.c
merge
[plan9front.git] / sys / src / ape / lib / ap / plan9 / getppid.c
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fcntl.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <errno.h>
7 #include "sys9.h"
8
9 pid_t
10 getppid(void)
11 {
12         int n, f;
13         char ppidbuf[15];
14
15         f = open("#c/ppid", 0);
16         n = read(f, ppidbuf, sizeof ppidbuf);
17         if(n < 0)
18                 errno = EINVAL;
19         else
20                 n = atoi(ppidbuf);
21         close(f);
22         return n;
23 }