title: How to do something in C when a process terminates without hanging the program?
body: <p>Currently, I'm learning about processes on the UNIX system.</p>
  <p>My issue is, I need to do something every time a background process terminates. That means that I can't use the typical functionality of waitpid because then the process won't be running in the background and it'll hang the program.</p>
  <p>I'm also aware of the SIGCHLD signal which is sent whenever a child of the parent process is terminated however I'm not aware of how to get the process id of the said process which I will need.</p>
  <p>What is the proper way to go about this in C? I've tried things such as WNOHANG option on waitpid however that of course only gets called once so I don't see how I could make that apply to my current situation.</p>