10 int pid, fd, size, i, mem;
11 char filename[17], buf[256], *ptr, *end;
14 snprintf (filename, 17, "/proc/%d/stat", pid);
15 fd = open (filename, O_RDONLY);
16 size = read (fd, buf, 240);
18 for (i = 0; i < 22; i++)
19 ptr = (char *) strchr (ptr, ' ') + 1;
20 end = (char *) strchr (ptr, ' ');
22 sscanf (ptr, "%d", &mem);