What I did in the past is to create a channel in the parent process and pass the end of the recording of this channel to the child. The parent never closes the end of the reading, and the child watches the end of the record close. If the end of the record ever closes, it means the parent has exited. You will also need to mark the parent end of the pipe to close exec.
source share