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 <stdio.h> 8 #include "sys9.h" 9 #include "lib.h" 10 11 pid_t getpgrp(void)12getpgrp(void) 13 { 14 int n, f, pid; 15 char pgrpbuf[15], fname[30]; 16 17 pid = getpid(); 18 sprintf(fname, "/proc/%d/noteid", pid); 19 f = open(fname, 0); 20 n = read(f, pgrpbuf, sizeof pgrpbuf); 21 if(n < 0) 22 _syserrno(); 23 else 24 n = atoi(pgrpbuf); 25 close(f); 26 return n; 27 } 28