If the first argument to kill is < -1, the signal is sent to all processes with process group id equal to the absolute value of the first argument.
Here is an example showing the pitfalls and the need changing the process group with setpgrp.
int main(int argc, char *argv[]) { int pid1; printf("my pid = %d\n", getpid()); if ((pid1 = fork()) == 0) { printf("first child: pid = %d, gpid = %d\n", getpid(), getpgrp()); int pid2; if ((pid2 = fork()) == 0) { printf("first child's child: pid = %d, gpid = %d\n", getpid(), getpgrp()); sleep(10); printf("c\n"); exit(0); } waitpid(pid2, 0, 0); printf("b\n"); exit(1); } sleep(1); printf("pid1 = %d\n", pid1); kill(-pid1, SIGCHLD); waitpid(pid1, 0, 0); printf("a\n"); return 0; }