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:
parent
2df3499e81
commit
04d4763926
@ -437,8 +437,14 @@ Serial::SerialImpl::close ()
|
|||||||
{
|
{
|
||||||
if (is_open_ == true) {
|
if (is_open_ == true) {
|
||||||
if (fd_ != -1) {
|
if (fd_ != -1) {
|
||||||
::close (fd_); // Ignoring the outcome
|
int retVal;
|
||||||
fd_ = -1;
|
retVal=::close (fd_);
|
||||||
|
if (retVal==0)
|
||||||
|
fd_ = -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
THROW (IOException, errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is_open_ = false;
|
is_open_ = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -260,7 +260,15 @@ Serial::SerialImpl::close ()
|
|||||||
{
|
{
|
||||||
if (is_open_ == true) {
|
if (is_open_ == true) {
|
||||||
if (fd_ != INVALID_HANDLE_VALUE) {
|
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;
|
fd_ = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
is_open_ = false;
|
is_open_ = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user