diff --git a/executables/referenceApp/platforms/posix/main/src/systems/TapEthernetSystem.cpp b/executables/referenceApp/platforms/posix/main/src/systems/TapEthernetSystem.cpp index 163a88353ca..c2054025fab 100644 --- a/executables/referenceApp/platforms/posix/main/src/systems/TapEthernetSystem.cpp +++ b/executables/referenceApp/platforms/posix/main/src/systems/TapEthernetSystem.cpp @@ -33,6 +33,7 @@ void TapEthernetSystem::run() void TapEthernetSystem::shutdown() { + _driver.stop(); _rxTimeout.cancel(); transitionDone(); } diff --git a/platforms/posix/bsp/tapEthernetDriver/src/TapEthernetDriver.cpp b/platforms/posix/bsp/tapEthernetDriver/src/TapEthernetDriver.cpp index 3ed4d8252a7..1c4de5365f3 100644 --- a/platforms/posix/bsp/tapEthernetDriver/src/TapEthernetDriver.cpp +++ b/platforms/posix/bsp/tapEthernetDriver/src/TapEthernetDriver.cpp @@ -64,11 +64,29 @@ TapEthernetDriver::TapEthernetDriver(::etl::array const macAdd bool TapEthernetDriver::start(char const* const ifName) { - _tapFd = allocTapInterface(ifName); - return _tapFd >= 0; + if (_tapFd >= 0) + { + close(_tapFd); + _tapFd = -1; + } + + int const fd = allocTapInterface(ifName); + if (fd < 0) + { + return false; + } + _tapFd = fd; + return true; } -void TapEthernetDriver::stop() { _tapFd = -1; } +void TapEthernetDriver::stop() +{ + if (_tapFd >= 0) + { + close(_tapFd); + _tapFd = -1; + } +} void TapEthernetDriver::readFrame() {