1 2 pid_t pid; 3 4 void sigint_handler(int sig) 5 { 6 printf("pid %d got SIGINT, terminating\n", getpid()); 7 exit(0); 8 } 9 10 11 int main() 12 { 13 14 Signal(SIGINT, sigint_handler); 15 if ( (pid = fork()) == 0 ) { 16 setpgid(0,0); 17 printf("child pid = %d, gid = %d\n", getpid(), getpgrp()); 18 pause(); 19 } 20 printf("parent pid = %d, gid = %d\n", getpid(), getpgrp()); 21 pause(); 22 23 return 0; 24 }