--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <signal.h>
+#include <sys/wait.h>
+
+pid_t children[5];
+
+void announce_death() {
+
+ printf("i'm pid #%lu and i died.\n", (long) getpid());
+}
+
+int main(int argc, char *argv[]) {
+
+ pid_t our_pid;
+ our_pid = getpid();
+
+ for(int i = 0; i < 5; i++) {
+ if((children[i] = fork()) == 0)
+ goto child;
+ else
+ sleep(1);
+ }
+
+ for(int i = 0; i < 5; i++) {
+
+ kill(children[i], SIGTERM);
+ wait(0);
+ }
+
+ return 0;
+
+ child:
+ printf("i'm pid #%lu!\n", (long)getpid());
+ atexit(announce_death);
+ exit(0);
+}