I have some C code which uses fork()
+exec()
, wait()
(or waitpid()
) and kill()
- and assumes they exist after including the relevant POSIX headers.
Now, I want to make this code as multi-platform as possible - with minimal changes. 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.
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?
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.