Use libutil on macOS and Linux
Libutil gives abstractions for OS-specific TTY operations. When using these abstractions across macOS and Linux, use this preprocessing statement for the appropriate header:
#ifdef __APPLE__
#include <util.h>
#else
#include <pty.h>
#endif
If using CMake, ensure the library and header are found:
find_library(UTIL_LIBRARY NAMES util)
if(APPLE)
find_path(UTIL_INCLUDE_DIR NAMES util.h)
elseif(UNIX)
find_path(UTIL_INCLUDE_DIR NAMES pty.h)
endif()