title: How to fork, wait on and kill processes in a platform-independent way?
body: <p>I have some C code which uses <code>fork()</code>+<code>exec()</code>, <code>wait()</code> (or <code>waitpid()</code>) and <code>kill()</code> - and assumes they exist after including the relevant POSIX headers.</p>
  
  <p>Now, I want to make this code as multi-platform as possible - <strong>with minimal changes</strong>. So, no introduction of third-party library dependencies, and no implementing these facilities on systems that don't have them. However, it is important for me to go beyond just Linux, Windows and Mac OS. My tool for doing so is CMake, which the project with this code uses; and the C preprocessor. Maybe a smidgen bit of glue code in C proper.</p>
  
  <p>My question: What should I check for, what should I put in a generated include file, and how should I modify my code calling these functions to effect the same behavior on both POSIX and various non-POSIX platforms?</p>
  
  <p>PS - I realize many platforms don't have Unix-style signals. Let's assume for the sake of discussion I'm only terminating processes, not sending other signals.</p>