1#include <sys/ioctl.h> 2#include <termios.h> 3#include <unistd.h> 4 5pid_t tcgetpgrp(int fd) { 6 int pgrp; 7 if (ioctl(fd, TIOCGPGRP, &pgrp) < 0) 8 return -1; 9 return pgrp; 10} 11