in reply to using waitpid() with signals

A couple of thoughts. First, if the parent does nothing else besides waiting on the child, it could have simply exec-uted that without forking. But I assume you've reasons to do it the more complicated way.

Secondly. If the parent process was invoked from shell as usual, it should be properly running as a process leader. Cleaning up can then be made simple and robust: just kill the entire process group.

The act of waiting on a subtask can also be accomplished differently. One might select or read on a pipe/socketpair to detect the termination of the other end.

AFAIC, there is nothing wrong with having the waitpid in a signal handler as in your second example.