1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 11:44:53 +08:00

Added return value control in Serial::SerialImpl::close () in unix.cc and win.cc

This commit is contained in:
Konstantina Kastanara 2014-05-07 18:49:37 +03:00
parent 2df3499e81
commit 04d4763926
2 changed files with 17 additions and 3 deletions

View File

@ -437,8 +437,14 @@ Serial::SerialImpl::close ()
{
if (is_open_ == true) {
if (fd_ != -1) {
::close (fd_); // Ignoring the outcome
fd_ = -1;
int retVal;
retVal=::close (fd_);
if (retVal==0)
fd_ = -1;
else
{
THROW (IOException, errno);
}
}
is_open_ = false;
}

View File

@ -260,7 +260,15 @@ Serial::SerialImpl::close ()
{
if (is_open_ == true) {
if (fd_ != INVALID_HANDLE_VALUE) {
CloseHandle(fd_);
int retVal;
retVal=CloseHandle(fd_);
if (retVal==0)
{
stringstream ss;
ss << "Error while closing serial port: " << GetLastError();
THROW (IOException, ss.str().c_str());
}
else
fd_ = INVALID_HANDLE_VALUE;
}
is_open_ = false;