diff mbox

[v5,23/25] wpaspy: add terminate support

Message ID 1457083241-7492-24-git-send-email-janusz.dziedzic@tieto.com
State Accepted
Headers show

Commit Message

Janusz.Dziedzic@tieto.com March 4, 2016, 9:20 a.m. UTC
This will terminate wpa_supplicant/hostapd

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 wpaspy/wpaspy.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py
index 7d6fadf..2b336a5 100644
--- a/wpaspy/wpaspy.py
+++ b/wpaspy/wpaspy.py
@@ -196,6 +196,16 @@  class Ctrl:
             return None
         raise Exception("DETACH failed")
 
+    def terminate(self):
+        if self.attached:
+            try:
+                self.detach()
+            except Exception, e:
+                # Need to ignore this allow the socket to be closed
+                self.attached = False
+        self.request("TERMINATE")
+        self.close()
+
     def pending(self, timeout=0):
         [r, w, e] = select.select([self.s], [], [], timeout)
         if r: