wjwwood / serial

Cross-platform, Serial Port library written in C++
http://wjwwood.github.com/serial/
MIT License
2.11k stars 1.03k forks source link

unix: exceptions in Serial::SerialImpl::reconfigurePort makes opened file descriptor hang in system. #246

Open detorto opened 3 years ago

detorto commented 3 years ago

If you try to create serial::Serial object, and something went wrong inreconfigurePortmethod (in my case - tcgetattr) - isOpened flag stays false, and ::close(_fd) method not called in destructor. This makes opened descriptors hang, and in autodetection case, with full cycle over all available ports - exceeds the limits of opened fd's.

Probably, just need to remove if (is_open_ == true) condition in Serial::SerialImpl::close ()