]> git.lizzy.rs Git - plan9front.git/blob - sys/src/ape/lib/ap/plan9/getppid.c
audiohda: fix syntax error
[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 <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <string.h>
8 #include "sys9.h"
9
10 pid_t
11 getppid(void)
12 {
13         char buf[32];
14         int f;
15
16         snprintf(buf, sizeof(buf), "/proc/%d/ppid", getpid());
17         f = open(buf, 0);
18         if(f < 0)
19                 return 0;
20         memset(buf, 0, sizeof(buf));
21         read(f, buf, sizeof(buf)-1);
22         close(f);
23         return atol(buf);
24 }