#if defined(__FreeBSD__) #include // ioctl and constants #include // openpty #include // ptsname_r #include // tcgetpgrp #elif defined(__linux__) #define _GNU_SOURCE // ptsname_r #include // openpty #include // ptsname_r #include // ioctl and constants #include // tcgetpgrp, setsid #elif defined(__APPLE__) #include // ioctl and constants #include // ioctl and constants for TIOCPTYGNAME #include #include // tcgetpgrp #include // openpty #ifndef tiocsctty #define tiocsctty 536900705 #endif #ifndef tiocswinsz #define tiocswinsz 2148037735 #endif #ifndef tiocgwinsz #define tiocgwinsz 1074295912 #endif #else #error "unsupported platform" #endif