Serial port and CMake magic fixes

* Reworked serial port redirection code, now CPU usage down to nearly 0% and connection issue / lost character fixed.
* Fixed broken commit for smartcard, now properly using WaitForMultipleObjects
* Fixed detection of ```pthread_tryjoin_np``` by cmake, now defining necessary symbols