Use libc to be more resilient and compatible.
The first commit just switches to calling the functions defined in libc instead of trying to link against them directly. This fixes the first issue on some platforms like illumos/solaris where cfmakeraw
isn't defined but libc includes a shim.
The second commit uses the constant TCSANOW
instead of hardcoding it since it is 0 on Linux but not all other platforms. (Also use STDOUT_FILENO
for consistency).
With these two fixes, cargo test passes for me without a linker error (first issue) or failing with invalid argument (second issue).