mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
Added return value control in Serial::SerialImpl::close () in unix.cc and win.cc
This commit is contained in:
parent
2df3499e81
commit
04d4763926
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user