From 6ed0e1d49b7fa8833f9e6951c500e34f9896eba0 Mon Sep 17 00:00:00 2001 From: Kent Williams Date: Sun, 16 Apr 2017 16:54:50 -0700 Subject: [PATCH 1/2] Added close serial port to device_destruct in unix serial.cc --- libsweep/src/unix/serial.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libsweep/src/unix/serial.cc b/libsweep/src/unix/serial.cc index 18f35b6..4d0ffbf 100644 --- a/libsweep/src/unix/serial.cc +++ b/libsweep/src/unix/serial.cc @@ -353,6 +353,7 @@ void device_destruct(device_s serial) { error_s ignore = nullptr; device_flush(serial, &ignore); + close(serial->fd); (void)ignore; // nothing we can do here delete serial; From c7cafacf0bc27ecb8af552154b74cd1bc1c50796 Mon Sep 17 00:00:00 2001 From: Kent Williams Date: Tue, 18 Apr 2017 10:56:55 -0700 Subject: [PATCH 2/2] Added assertion to file descriptor close --- libsweep/src/unix/serial.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libsweep/src/unix/serial.cc b/libsweep/src/unix/serial.cc index 4d0ffbf..448ccb4 100644 --- a/libsweep/src/unix/serial.cc +++ b/libsweep/src/unix/serial.cc @@ -353,7 +353,11 @@ void device_destruct(device_s serial) { error_s ignore = nullptr; device_flush(serial, &ignore); - close(serial->fd); + + if (close(serial->fd) == -1) { + SWEEP_ASSERT(false && "closing file descriptor during destruct failed"); + } + (void)ignore; // nothing we can do here delete serial;