From 4c783e558422d27279ad0812899b1f641dec8643 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 5 Dec 2018 06:38:55 +0800 Subject: [PATCH] [android] fix untracked pid in Android (#3343) --- src/posix/platform/hdlc_interface.cpp | 7 ++++++- src/posix/platform/hdlc_interface.hpp | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index 8583065d0..c1c94ac07 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -121,9 +121,14 @@ exit: return error; } +HdlcInterface::~HdlcInterface(void) +{ + Deinit(); +} + void HdlcInterface::Deinit(void) { - assert(mSockFd != -1); + VerifyOrExit(mSockFd != -1); VerifyOrExit(0 == close(mSockFd), perror("close NCP")); VerifyOrExit(-1 != wait(NULL), perror("wait NCP")); diff --git a/src/posix/platform/hdlc_interface.hpp b/src/posix/platform/hdlc_interface.hpp index 735241960..bd39370e4 100644 --- a/src/posix/platform/hdlc_interface.hpp +++ b/src/posix/platform/hdlc_interface.hpp @@ -79,6 +79,12 @@ public: */ explicit HdlcInterface(Callbacks &aCallbacks); + /** + * This destructor deinitializes the object. + * + */ + ~HdlcInterface(void); + /** * This method initializes the interface to the Radio Co-processor (RCP) *