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