If you use waitpid()more or less, as shown, you will be given the PID of one of the child processes that died - usually this will be the only process that died, but if you get a flurry of them, you can get one signal and many corpses to collect. So use:
void sigchld_handler(int signum)
{
pid_t pid;
int status;
while ((pid = waitpid(-1, &status, WNOHANG)) != -1)
{
unregister_child(pid, status);
}
}
&status NULL, .