diff options
author | antialias <antialias@leap.se> | 2012-10-12 15:49:28 -0400 |
---|---|---|
committer | antialias <antialias@leap.se> | 2012-10-12 15:49:28 -0400 |
commit | 0875a3d498c30187a40a788d3bd1eefa9c5924e2 (patch) | |
tree | e9e7291e501d2e0efae02996d4774532101ca6b1 /src/leap/eip/openvpnconnection.py | |
parent | dca30766421cc692726c61fe2d502ae263e6121b (diff) |
stopping openvpn via management interface.
Diffstat (limited to 'src/leap/eip/openvpnconnection.py')
-rw-r--r-- | src/leap/eip/openvpnconnection.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index 14839f6b..96df4f1d 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -174,17 +174,22 @@ to be triggered for each one of them. def cleanup(self): """ - terminates child subprocess + terminates openvpn child subprocess """ - # XXX we should send a quit process using management - # interface. if self.subp: - try: - self.subp.terminate() - except OSError: - logger.error('cannot terminate subprocess!' + self._stop() + RETCODE = self.subp.wait() + if RETCODE: + logger.error('cannot terminate subprocess! ' '(maybe openvpn still running?)') + def _stop(self): + """ + stop openvpn process + """ + logger.debug("disconnecting...") + self._send_command("signal SIGTERM\n") + # # management methods # @@ -221,9 +226,16 @@ to be triggered for each one of them. """ Read as much as available. Position seek pointer to end of stream """ - b = self.tn.read_eager() - while b: + try: b = self.tn.read_eager() + except EOFError: + logger.debug("Could not read from socket. Assuming it died.") + return + while b: + try: + b = self.tn.read_eager() + except EOFError: + logger.debug("Could not read from socket. Assuming it died.") def connected(self): """ |